> I'd sure like a confirmation Andrew's suggestion of using a Condition to replace wait notity notifyall, will that work?
>
Alas, I have just discovered that ReentrantLock as currently present is defective, so DON't use it. You can create an equivalent signaling mechanism using Cell; it'll be faster since it is purely in user-space.
The problem with ReentrantLock is this. It is thread-id based, so an unlock will have to be performed on the same thread as a lock.
Say task A and task B use the same lock. A calls lock(), then yields. B then calls lock(), which succeeds because (a) it happens to be scheduled on the same thread that A executed on, and (ii) it is reentrant. Now two logically different threads own the same lock. It gets worse with unlock. If B unlocks, the lock is released, but A does not know that.
Mixing thread and task signaling mechanisms is error-prone; which is why Go doesn't export anything task or thread identity-related (no threadlocals for example).
--sriram.
> On Tuesday, April 16, 2013 9:22:41 AM UTC-5, Andrew Bate wrote:
> Does any one know of any difficulties with the strategy of obtaining a condition with kilim.ReentrantLock#newCondition() and then using that Condition objects' signal(), signalAll() and await() methods with Kilim?
>
> This should be a drop in replacement for notify(), notifyAll() and wait() with Kilim, correct?
>
> Best wishes,
>
> Andrew
>
>
>
> On Friday, 11 February 2011 19:27:46 UTC, Ron wrote:
> Hi All,
>
> I've come to understand how to change code that does Thread/run to
> Task/execute, and how
> to change synchronized blocks and methods to use the ReentrantLock
> class for locking.
>
> What I don't know how to handle, is code that is doing wait/notify or
> notifyall calls. Is there
> a way to get rid of these calls, and if not what effect do they have
> on how Kilim works?
>
> Regards,
>
> Ron
>
> --
> You received this message because you are subscribed to the Google Groups "kilimthreads" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
kilimthreads...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.