[chuck-users] Events as shared instance variables across shreds
Spencer Salazar
ssalazar at CS.Princeton.EDU
Tue Jan 30 16:49:55 EST 2007
Hi David,
Both approaches should be equivalent--in either case the same
underlying Event is being accessed.
spencer
On Jan 29, 2007, at 9:53 PM, David Michael wrote:
> Bear (bare?) with me,
>
> Is it advisable to have Events as instance variables so that shreds
> sporked from that instance all reference this internal event?
>
> The code below works in practice.
> (I have not run the code example, but I do something similar in a
> program).
>
> Are there any pitfalls to doing this, rather than explicitly passing
> in the Event, as is shown in the language tutorials?
>
> Many thanks in advance,
> D
>
>
> // event as instance variable across shreds
> // -----------------------------------------------------------
>
> class Object
> {
> new Event @=> Event event;
>
> function first()
> {
> while(true)
> {
> this.event.signal();
> 1::second => now;
> }
> }
>
> function second()
> {
> while(true)
> {
> this.event => now;
> <<< "recieved event" >>>;
> }
> }
> }
>
> Object object;
>
> spork ~ object.first();
> spork ~ object.second();
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
More information about the chuck-users
mailing list