Hi Kenton,

thanks for the suggestion! Would you say that returning the new promise is 
so much preferable that it is worth jumping through some extra hoops for it?

The problem is that the user's callback function may call the enable or 
disable methods of the callback arbitrarily (especially for other callback 
types, e.g. DelayCallback, that do not reschedule themselves by default). 
Both methods would have to know if the callback is currently executing. If 
not, they would have to schedule the callback themselves, otherwise they 
would have to inform the caller whether to reschedule the callback or not. 
As is (by detaching the executing promise), the enable method can simply 
schedule the callback, blindly (over)writing the promise in the 
implementation struct, and disable can simply assign nullptr to the 
promise, without caring who the caller is.

As for running kj on top of libev, I looked into the example you linked, 
but decided that, especially since I use quite a lot of timers, it would be 
cleaner to use only a single event library, especially since all uses of 
libev were already wrapped in a custom event system interface.

Thanks!
Johannes

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to