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.8 by root, Sun Apr 14 01:18:38 2002 UTC vs.
Revision 1.9 by root, Sat Mar 22 18:50:32 2003 UTC

9confess (const char *msg) 9confess (const char *msg)
10{ 10{
11 dSP; 11 dSP;
12 12
13 PUSHMARK(SP); 13 PUSHMARK(SP);
14 XPUSHs (sv_2mortal(newSVpv("only one coroutine can wait for an event",0))); 14 XPUSHs (sv_2mortal(newSVpv("only one coroutine can wait for an event at any given time",0)));
15 PUTBACK; 15 PUTBACK;
16 call_pv ("Carp::confess", G_VOID); 16 call_pv ("Carp::confess", G_VOID);
17} 17}
18 18
19#include "EventAPI.h" 19#include "EventAPI.h"
20#include "../Coro/CoroAPI.h" 20#include "../Coro/CoroAPI.h"
21
22#ifndef PE_PERLCB
23# define PE_PERLCB 0x020 /* not public, but we need it :( */
24#endif
21 25
22#define CD_CORO 0 26#define CD_CORO 0
23#define CD_TYPE 1 27#define CD_TYPE 1
24#define CD_OK 2 28#define CD_OK 2
25#define CD_PRIO 3 /* hardcoded in Coro::Event */ 29#define CD_PRIO 3 /* hardcoded in Coro::Event */
78 82
79PROTOTYPES: ENABLE 83PROTOTYPES: ENABLE
80 84
81BOOT: 85BOOT:
82{ 86{
83 I_EVENT_API("Coro::Event"); 87 I_EVENT_API ("Coro::Event");
84 I_CORO_API ("Coro::Event"); 88 I_CORO_API ("Coro::Event");
85 89
86 /* create a fake idle handler (we only ever call now) */ 90 /* create a fake idle handler (we only ever call now) */
87 scheduler = GEventAPI->new_idle (0, 0); 91 scheduler = GEventAPI->new_idle (0, 0);
88 scheduler->base.callback = scheduler_cb; 92 scheduler->base.callback = scheduler_cb;
96_install_std_cb(self,type) 100_install_std_cb(self,type)
97 SV * self 101 SV * self
98 int type 102 int type
99 CODE: 103 CODE:
100 pe_watcher *w = GEventAPI->sv_2watcher (self); 104 pe_watcher *w = GEventAPI->sv_2watcher (self);
101 AV *priv = newAV ();
102 SV *rv = newRV_noinc ((SV *)priv);
103 105
104 av_extend (priv, CD_MAX); 106 if (WaFLAGS (w) & PE_PERLCB)
105 av_store (priv, CD_CORO, &PL_sv_undef); 107 croak ("Coro::Event watchers must not have a perl callback (see Coro::Event), caught");
106 av_store (priv, CD_TYPE, newSViv (type)); 108 {
107 av_store (priv, CD_OK , &PL_sv_no); 109 AV *priv = newAV ();
108 av_store (priv, CD_PRIO, newSViv (0)); 110 SV *rv = newRV_noinc ((SV *)priv);
109 av_store (priv, CD_HITS, newSViv (0));
110 av_store (priv, CD_GOT , type ? newSViv (0) : &PL_sv_undef);
111 SvREADONLY_on (priv);
112 111
113 w->callback = coro_std_cb; 112 av_extend (priv, CD_MAX);
114 w->ext_data = priv; 113 av_store (priv, CD_CORO, &PL_sv_undef);
114 av_store (priv, CD_TYPE, newSViv (type));
115 av_store (priv, CD_OK , &PL_sv_no);
116 av_store (priv, CD_PRIO, newSViv (0));
117 av_store (priv, CD_HITS, newSViv (0));
118 av_store (priv, CD_GOT , type ? newSViv (0) : &PL_sv_undef);
119 SvREADONLY_on (priv);
115 120
116 hv_store ((HV *)SvRV (self), 121 w->callback = coro_std_cb;
117 EV_CLASS, strlen (EV_CLASS), 122 w->ext_data = priv;
118 rv, 0);
119 123
124 hv_store ((HV *)SvRV (self),
125 EV_CLASS, strlen (EV_CLASS),
126 rv, 0);
127
120 GEventAPI->start (w, 0); 128 GEventAPI->start (w, 0);
129 }
121 130
122void 131void
123_next(self) 132_next(self)
124 SV * self 133 SV * self
125 CODE: 134 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines