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

Comparing Coro/Coro/State.xs (file contents):
Revision 1.133 by root, Thu Jan 4 20:14:19 2007 UTC vs.
Revision 1.136 by root, Fri Jan 12 01:05:55 2007 UTC

112#else 112#else
113# define LOCK (void)0 113# define LOCK (void)0
114# define UNLOCK (void)0 114# define UNLOCK (void)0
115#endif 115#endif
116 116
117/* helper storage struct for Coro::AIO */
117struct io_state 118struct io_state
118{ 119{
119 int errorno; 120 int errorno;
120 I32 laststype; 121 I32 laststype;
121 int laststatval; 122 int laststatval;
472 473
473 /* free all temporaries */ 474 /* free all temporaries */
474 FREETMPS; 475 FREETMPS;
475 assert (PL_tmps_ix == -1); 476 assert (PL_tmps_ix == -1);
476 477
478 /* unwind all extra stacks */
477 POPSTACK_TO (PL_mainstack); 479 POPSTACK_TO (PL_mainstack);
480
481 /* unwind main stack */
482 dounwind (-1);
478 } 483 }
479 484
480 while (PL_curstackinfo->si_next) 485 while (PL_curstackinfo->si_next)
481 PL_curstackinfo = PL_curstackinfo->si_next; 486 PL_curstackinfo = PL_curstackinfo->si_next;
482 487
801#define TRANSFER(ta) transfer ((ta).prev, (ta).next) 806#define TRANSFER(ta) transfer ((ta).prev, (ta).next)
802 807
803static int 808static int
804coro_state_destroy (struct coro *coro) 809coro_state_destroy (struct coro *coro)
805{ 810{
806 if (coro->refcnt--)
807 return 0;
808
809 if (coro->flags & CF_DESTROYED) 811 if (coro->flags & CF_DESTROYED)
810 return 0; 812 return 0;
811 813
812 coro->flags |= CF_DESTROYED; 814 coro->flags |= CF_DESTROYED;
813 815
837 839
838 return 1; 840 return 1;
839} 841}
840 842
841static int 843static int
842coro_state_clear (pTHX_ SV *sv, MAGIC *mg) 844coro_state_free (pTHX_ SV *sv, MAGIC *mg)
843{ 845{
844 struct coro *coro = (struct coro *)mg->mg_ptr; 846 struct coro *coro = (struct coro *)mg->mg_ptr;
845 mg->mg_ptr = 0; 847 mg->mg_ptr = 0;
846 848
849 if (--coro->refcnt < 0)
850 {
847 coro_state_destroy (coro); 851 coro_state_destroy (coro);
848
849 if (!coro->refcnt)
850 Safefree (coro); 852 Safefree (coro);
853 }
851 854
852 return 0; 855 return 0;
853} 856}
854 857
855static int 858static int
862 return 0; 865 return 0;
863} 866}
864 867
865static MGVTBL coro_state_vtbl = { 868static MGVTBL coro_state_vtbl = {
866 0, 0, 0, 0, 869 0, 0, 0, 0,
867 coro_state_clear, 870 coro_state_free,
868 0, 871 0,
869#ifdef MGf_DUP 872#ifdef MGf_DUP
870 coro_state_dup, 873 coro_state_dup,
871#else 874#else
872# define MGf_DUP 0 875# define MGf_DUP 0
1202 break; 1205 break;
1203 } 1206 }
1204 1207
1205 BARRIER; 1208 BARRIER;
1206 TRANSFER (ta); 1209 TRANSFER (ta);
1210
1211 if (GIMME_V != G_VOID && ta.next != ta.prev)
1212 XSRETURN_YES;
1207} 1213}
1208 1214
1209bool 1215bool
1210_destroy (SV *coro_sv) 1216_destroy (SV *coro_sv)
1211 CODE: 1217 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines