[chuck-users] implementing a "wait for signal with timeout"

N. Cameron Britt nbritt at princeton.edu
Tue Jun 9 10:57:58 EDT 2009


Attached is a solution I came up with for this problem that I used in my
PLOrk piece this spring. I spork a "possibility" for something to happen,
which waits on an event. Immediately after I spork a "timeout" shred that
kills the possibility shred if the event doesn't come in time.

One downside of this (I'm sure there are others I haven't thought of!)  is
that using Machine.remove causes stuff to print in the console. To get rid
of that I piped the output to grep. From the command line run:
chuck timeout.ck 2>&1 | grep -v removing

Cameron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20090609/117ab11d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: timeout.ck
Type: application/octet-stream
Size: 783 bytes
Desc: not available
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20090609/117ab11d/attachment-0001.obj>


More information about the chuck-users mailing list