[chuck-users] /examples/event/event_extend.ck

Kassen signal.automatique at gmail.com
Thu Jan 31 11:15:16 EST 2008

On 31/01/2008, Renato Fabbri <renato.fabbri at gmail.com> wrote:
> hi Chuckers,

Hello, Renato,

I have two questions regarding the example bunddled with chuck in
> /examples/event/event_extend.ck (attached for convevience)
> first, if the function hi is sporked four times, why does it run only
> once? i mean, in each loop that takes one second i only see one
> integer being printed. Anyway, i have removed 3 of the 4 spork
> statements and it seems to run just the same way.

This is because the event is "signalled" and not "broadcasted". In the case
of signalling only the first shred on the event's waiting list is notified,
when you broadcast a event *all* shreds waiting for it will wake up.

second, why is the return type of hi specified as int when it doenst
> return anything? I have exchaged the return type for void and it seems
> to run normally as well.

I think that's just a plain error. You are right, it doesn't return a thing
and I think that sporked functions *can't* return anything, the whole point
of sporking is that the code doesn't wait for the function to finish so it
couldn't return a thing. Well spotted.

Hope that helps,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20080131/f4692090/attachment.htm 

More information about the chuck-users mailing list