ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Event/Event.xs
(Generate patch)

Comparing Coro/Event/Event.xs (file contents):
Revision 1.17 by root, Mon Dec 4 22:05:49 2006 UTC vs.
Revision 1.18 by root, Fri Dec 29 11:37:49 2006 UTC

41} 41}
42 42
43static void 43static void
44asynccheck_hook (void *data) 44asynccheck_hook (void *data)
45{ 45{
46 /* ceding from C means allocating a stack, but we assume this is a rare case */ 46 /* this loops as long as we have _other_ coros with the same or higher priority */
47 while (CORO_NREADY && CORO_CEDE)
48 ;
49}
50
51static double
52prepare_hook (void *data)
53{
54 /* this yields once to another coro with any priority */
47 while (CORO_NREADY) 55 if (CORO_NREADY)
48 CORO_CEDE; 56 {
57 CORO_CEDE_NOTSELF;
58 /*
59 * timers might have changed, and Event fails to notice this
60 * so we have to assume the worst. If Event didn't have that bug,
61 * we would only need to do this if CORO_NREADY is != 0 now.
62 */
63 return 0.;
64 }
65 else
66 return 85197.73; /* this is as good as any value, but it factors badly with common values */
49} 67}
50 68
51MODULE = Coro::Event PACKAGE = Coro::Event 69MODULE = Coro::Event PACKAGE = Coro::Event
52 70
53PROTOTYPES: ENABLE 71PROTOTYPES: ENABLE
56{ 74{
57 I_EVENT_API ("Coro::Event"); 75 I_EVENT_API ("Coro::Event");
58 I_CORO_API ("Coro::Event"); 76 I_CORO_API ("Coro::Event");
59 77
60 GEventAPI->add_hook ("asynccheck", (void *)asynccheck_hook, 0); 78 GEventAPI->add_hook ("asynccheck", (void *)asynccheck_hook, 0);
79 GEventAPI->add_hook ("prepare", (void *)prepare_hook, 0);
61} 80}
62 81
63void 82void
64_install_std_cb (SV *self, int type) 83_install_std_cb (SV *self, int type)
65 CODE: 84 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines