On Tue, Jun 14, 2011 at 8:48 AM, Andreas Zwinkau <[email protected]> wrote:
> I want have an Activity A blocked, which is unlocked by another Activity
> B. How do i do this?
>
> I cannot use a Lock, because they work on Threads not Activities. Hence,
> if B is not accidentally executed by the same worker thread as A, then
> an exception is thrown.
Hi, Andreas,
The construct you're looking for is a conditional atomic section ("when").
The pattern could be something like this:
finish {
val sync = new Cell[Boolean](false);
async { // A
Console.ERR.println("A: Locking");
when (sync()) { Console.ERR.println("A: Unlocked"); }
}
async { // B
System.sleep(1000);
Console.ERR.println("B: Unlocking A");
atomic { sync() = true; }
}
}
Note that the "atomic" in B is needed for the update to be seen by A.
Hope this helps,
Igor
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users