… | |
… | |
540 | #if !PERL_VERSION_ATLEAST (5,9,0) |
540 | #if !PERL_VERSION_ATLEAST (5,9,0) |
541 | Safefree (PL_retstack); |
541 | Safefree (PL_retstack); |
542 | #endif |
542 | #endif |
543 | } |
543 | } |
544 | |
544 | |
|
|
545 | static size_t |
|
|
546 | coro_rss (struct coro *coro) |
|
|
547 | { |
|
|
548 | size_t rss = sizeof (coro); |
|
|
549 | |
|
|
550 | if (coro->mainstack) |
|
|
551 | { |
|
|
552 | rss += sizeof (coro->curstackinfo); |
|
|
553 | rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstackinfo->si_stack)) * sizeof (SV *); |
|
|
554 | rss += (coro->curstackinfo->si_cxmax + 1) * sizeof (PERL_CONTEXT); |
|
|
555 | |
|
|
556 | rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstack)) * sizeof (SV *); |
|
|
557 | |
|
|
558 | rss += coro->tmps_max * sizeof (SV *); |
|
|
559 | |
|
|
560 | rss += (coro->markstack_max - coro->markstack_ptr) * sizeof (I32); |
|
|
561 | |
|
|
562 | rss += coro->scopestack_max * sizeof (I32); |
|
|
563 | |
|
|
564 | rss += coro->savestack_max * sizeof (ANY); |
|
|
565 | |
|
|
566 | #if !PERL_VERSION_ATLEAST (5,9,0) |
|
|
567 | rss += coro->retstack_max * sizeof (OP *); |
|
|
568 | #endif |
|
|
569 | } |
|
|
570 | |
|
|
571 | return rss; |
|
|
572 | } |
|
|
573 | |
545 | /** coroutine stack handling ************************************************/ |
574 | /** coroutine stack handling ************************************************/ |
546 | |
575 | |
547 | static void |
576 | static void |
548 | setup_coro (pTHX_ struct coro *coro) |
577 | setup_coro (pTHX_ struct coro *coro) |
549 | { |
578 | { |
… | |
… | |
1345 | if (coro->hv) |
1374 | if (coro->hv) |
1346 | XPUSHs (sv_2mortal (newRV_inc ((SV *)coro->hv))); |
1375 | XPUSHs (sv_2mortal (newRV_inc ((SV *)coro->hv))); |
1347 | } |
1376 | } |
1348 | |
1377 | |
1349 | void |
1378 | void |
1350 | _eval (SV *coro_sv, SV *coderef) |
1379 | _eval (Coro::State coro, SV *coderef) |
1351 | CODE: |
1380 | CODE: |
1352 | { |
1381 | { |
1353 | struct coro *coro = SvSTATE (coro_sv); |
|
|
1354 | if (coro->mainstack) |
1382 | if (coro->mainstack) |
1355 | { |
1383 | { |
1356 | struct coro temp; |
1384 | struct coro temp; |
1357 | Zero (&temp, 1, struct coro); |
1385 | Zero (&temp, 1, struct coro); |
1358 | temp.save = CORO_SAVE_ALL; |
1386 | temp.save = CORO_SAVE_ALL; |
… | |
… | |
1383 | } |
1411 | } |
1384 | } |
1412 | } |
1385 | } |
1413 | } |
1386 | |
1414 | |
1387 | SV * |
1415 | SV * |
1388 | is_ready (SV *coro_sv) |
1416 | is_ready (Coro::State coro) |
1389 | PROTOTYPE: $ |
1417 | PROTOTYPE: $ |
1390 | ALIAS: |
1418 | ALIAS: |
1391 | is_ready = CF_READY |
1419 | is_ready = CF_READY |
1392 | is_running = CF_RUNNING |
1420 | is_running = CF_RUNNING |
1393 | is_new = CF_NEW |
1421 | is_new = CF_NEW |
1394 | is_destroyed = CF_DESTROYED |
1422 | is_destroyed = CF_DESTROYED |
1395 | CODE: |
1423 | CODE: |
1396 | struct coro *coro = SvSTATE (coro_sv); |
|
|
1397 | RETVAL = boolSV (coro->flags & ix); |
1424 | RETVAL = boolSV (coro->flags & ix); |
|
|
1425 | OUTPUT: |
|
|
1426 | RETVAL |
|
|
1427 | |
|
|
1428 | IV |
|
|
1429 | rss (Coro::State coro) |
|
|
1430 | PROTOTYPE: $ |
|
|
1431 | CODE: |
|
|
1432 | RETVAL = coro_rss (coro); |
1398 | OUTPUT: |
1433 | OUTPUT: |
1399 | RETVAL |
1434 | RETVAL |
1400 | |
1435 | |
1401 | |
1436 | |
1402 | MODULE = Coro::State PACKAGE = Coro |
1437 | MODULE = Coro::State PACKAGE = Coro |