Branch Coverage

src/future.c
Criterion Covered Total %
branch 5 734 0.6


line true false branch
113 0 0 if(!SvROK(sv) || !SvOBJECT(SvRV(sv)))
0 0 if(!SvROK(sv) || !SvOBJECT(SvRV(sv)))
116 0 0 if(sv_derived_from(sv, "Future") || sv_derived_from(sv, "Future::XS"))
0 0 if(sv_derived_from(sv, "Future") || sv_derived_from(sv, "Future::XS"))
128 0 0 struct FutureXS *self = INT2PTR(struct FutureXS *, SvIV(SvRV(sv)));
135 0 0 if(!cls)
147 0 0 if(capture_times)
154 0 0 if(future_debug)
155 0 0 self->constructed_at = newSVpvf("constructed at %s line %d", CopFILE(PL_curcop), CopLINE(PL_curcop));
190 0 0 EXTEND(SP, 1);
191 0 0 PUSHMARK(SP);
202 0 0 FREETMPS;
212 0 0 while(callbacksav && AvFILLp(callbacksav) > -1) {
0 0 while(callbacksav && AvFILLp(callbacksav) > -1) {
216 0 0 if(flags & CB_SEQ_ANY) {
223 0 0 SvREFCNT_dec(CB_NONSEQ_CODE(cb));
246 0 0 if(future_debug &&
0 0 if(future_debug &&
247 0 0 (!self->ready || (self->failure && !self->reported))) {
0 0 (!self->ready || (self->failure && !self->reported))) {
248 0 0 if(!self->ready)
249 0 0 warn("%" SVf " was %" SVf " and was lost near %s line %d before it was ready\n",
254 0 0 warn("%" SVf " was %" SVf " and was lost near %s line %d with an unreported failure of: %" SVf "\n",
273 0 0 while(revocationsav && AvFILLp(revocationsav) > -1) {
0 0 while(revocationsav && AvFILLp(revocationsav) > -1) {
303 0 0 return self->ready && !self->failure && !self->cancelled;
0 0 return self->ready && !self->failure && !self->cancelled;
0 0 return self->ready && !self->failure && !self->cancelled;
309 0 0 return self->ready && self->failure;
0 0 return self->ready && self->failure;
321 0 0 if(!self->on_cancel)
337 0 0 if(cb->flags & CB_SEQ_ANY) {
344 0 0 new->code = CB_NONSEQ_CODE(cb);
347 0 0 if(!self->callbacks)
362 0 0 EXTEND(SP, 3);
363 0 0 PUSHMARK(SP);
375 0 0 FREETMPS;
387 0 0 bool is_done = !self->cancelled && !is_fail;
0 0 bool is_done = !self->cancelled && !is_fail;
389 0 0 AV *result = (is_done) ? self->result :
390 0 0 (is_fail) ? self->failure :
393 0 0 SV *code = (is_done) ? cb->seq.thencode :
394 0 0 (is_fail) ? cb->seq.elsecode :
397 0 0 if(is_fail && result && av_count(result) > 1 && cb->seq.catches) {
0 0 if(is_fail && result && av_count(result) > 1 && cb->seq.catches) {
0 0 if(is_fail && result && av_count(result) > 1 && cb->seq.catches) {
0 0 if(is_fail && result && av_count(result) > 1 && cb->seq.catches) {
0 0 if(is_fail && result && av_count(result) > 1 && cb->seq.catches) {
399 0 0 if(SvOK(category)) {
0 0 if(SvOK(category)) {
0 0 if(SvOK(category)) {
401 0 0 if(he && HeVAL(he))
0 0 if(he && HeVAL(he))
406 0 0 if(!code || !SvOK(code))
0 0 if(!code || !SvOK(code))
0 0 if(!code || !SvOK(code))
0 0 if(!code || !SvOK(code))
414 0 0 PUSHMARK(SP);
415 0 0 if(flags & CB_SELF)
416 0 0 XPUSHs(selfsv);
417 0 0 if(flags & CB_RESULT)
418 0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
426 0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
431 0 0 if(!fseq)
434 0 0 future_failv(fseq, &ERRSV, 1);
436 0 0 FREETMPS;
446 0 0 FREETMPS;
449 0 0 if(!sv_is_future(f2)) {
468 0 0 bool is_done = !is_cancelled && !is_fail;
0 0 bool is_done = !is_cancelled && !is_fail;
470 0 0 AV *result = (is_done) ? self->result :
471 0 0 (is_fail) ? self->failure :
474 0 0 if(is_done && !(flags & CB_DONE))
0 0 if(is_done && !(flags & CB_DONE))
476 0 0 if(is_fail && !(flags & CB_FAIL))
0 0 if(is_fail && !(flags & CB_FAIL))
478 0 0 if(is_cancelled && !(flags & CB_CANCEL))
0 0 if(is_cancelled && !(flags & CB_CANCEL))
481 0 0 if(flags & CB_IS_FUTURE) {
487 0 0 PUSHMARK(SP);
488 0 0 XPUSHs(CB_NONSEQ_CODE(cb)); // really a Future RV
0 0 XPUSHs(CB_NONSEQ_CODE(cb)); // really a Future RV
489 0 0 if(result)
490 0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
493 0 0 if(is_done)
495 0 0 else if(is_fail)
500 0 0 FREETMPS;
503 0 0 else if(flags & CB_SEQ_ANY) {
506 0 0 if(!SvOK(fseq)) {
0 0 if(!SvOK(fseq)) {
0 0 if(!SvOK(fseq)) {
507 0 0 if(self->constructed_at)
517 0 0 if(f2 == fseq)
523 0 0 if(future_is_ready(f2)) {
524 0 0 if(!future_is_cancelled(f2))
526 0 0 else if(flags & CB_CANCEL)
541 0 0 SV *code = CB_NONSEQ_CODE(cb);
548 0 0 PUSHMARK(SP);
549 0 0 if(flags & CB_SELF)
550 0 0 XPUSHs(selfsv);
551 0 0 if((flags & CB_RESULT) && result)
0 0 if((flags & CB_RESULT) && result)
552 0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
558 0 0 FREETMPS;
566 0 0 if(rev->toclear_sv_at && SvROK(rev->toclear_sv_at)) {
0 0 if(rev->toclear_sv_at && SvROK(rev->toclear_sv_at)) {
574 0 0 if(!SvOK(rev->precedent_f))
0 0 if(!SvOK(rev->precedent_f))
0 0 if(!SvOK(rev->precedent_f))
582 0 0 if(self->empty_revocation_slots >= 8 && on_cancel &&
0 0 if(self->empty_revocation_slots >= 8 && on_cancel &&
0 0 if(self->empty_revocation_slots >= 8 && on_cancel &&
583 0 0 self->empty_revocation_slots >= AvFILL(on_cancel)/2) {
588 0 0 **end = AvARRAY(on_cancel) + AvFILL(on_cancel);
590 0 0 while(rdsv <= end) {
591 0 0 if(SvOK(*rdsv))
0 0 if(SvOK(*rdsv))
0 0 if(SvOK(*rdsv))
611 0 0 if(capture_times)
618 0 0 if(self->precedent_f) {
624 0 0 if(self->revoke_when_ready) {
626 0 0 for(size_t i = 0; i < av_count(revocations); i++) {
0 0 for(size_t i = 0; i < av_count(revocations); i++) {
639 0 0 if(!self->callbacks)
645 0 0 size_t i, n = av_count(callbacks);
646 0 0 for(i = 0; i < n; i++) {
661 0 0 if(self->ready) {
669 0 0 if(cb->flags & CB_SEQ_CANCEL)
673 0 0 if(cb->seq.thencode)
675 0 0 if(cb->seq.elsecode)
688 0 0 if(!CvANON(cv)) {
694 0 0 while(cop && OP_CLASS(cop) != OA_COP)
0 0 while(cop && OP_CLASS(cop) != OA_COP)
0 0 while(cop && OP_CLASS(cop) != OA_COP)
0 0 while(cop && OP_CLASS(cop) != OA_COP)
697 0 0 if(!cop)
700 0 0 return newSVpvf("__ANON__(%s line %d)", CopFILE((COP *)cop), CopLINE((COP *)cop));
707 0 0 if(self->cancelled)
710 0 0 if(self->ready)
723 0 0 if(self->cancelled)
726 0 0 if(self->ready)
730 0 0 if(n == 1 &&
0 0 if(n == 1 &&
742 0 0 EXTEND(SP, 1);
743 0 0 PUSHMARK(SP);
754 0 0 FREETMPS;
762 0 0 EXTEND(SP, 1);
763 0 0 PUSHMARK(SP);
774 0 0 FREETMPS;
782 0 0 EXTEND(SP, 1);
783 0 0 PUSHMARK(SP);
793 0 0 for(SSize_t i = 0; i < count; i++)
798 0 0 FREETMPS;
814 0 0 if(self->cancelled)
817 0 0 if(self->ready)
830 0 0 if(self->ready)
836 0 0 if(!self->on_cancel)
842 0 0 if(is_future) {
850 0 0 if(!codeself->revoke_when_ready)
865 0 0 if(is_future)
873 0 0 if(self->ready)
889 0 0 if(is_future)
897 0 0 if(self->ready)
913 0 0 if(is_future)
921 0 0 if(self->ready)
937 0 0 PUSHMARK(SP);
938 0 0 mXPUSHs(newSVsv(f));
943 0 0 FREETMPS;
951 0 0 if(await && !self->ready)
0 0 if(await && !self->ready)
954 0 0 if(!self->ready)
957 0 0 if(self->failure) {
961 0 0 if(av_count(self->failure) > 1) {
0 0 if(av_count(self->failure) > 1) {
966 0 0 PUSHMARK(SP);
967 0 0 EXTEND(SP, 1 + av_count(self->failure));
0 0 EXTEND(SP, 1 + av_count(self->failure));
0 0 EXTEND(SP, 1 + av_count(self->failure));
0 0 EXTEND(SP, 1 + av_count(self->failure));
0 0 EXTEND(SP, 1 + av_count(self->failure));
969 0 0 for(SSize_t i = 0; i < av_count(self->failure); i++)
0 0 for(SSize_t i = 0; i < av_count(self->failure); i++)
980 0 0 FREETMPS;
984 0 0 if(SvROK(exception) || SvPV_nolen(exception)[SvCUR(exception)-1] == '\n')
0 0 if(SvROK(exception) || SvPV_nolen(exception)[SvCUR(exception)-1] == '\n')
0 0 if(SvROK(exception) || SvPV_nolen(exception)[SvCUR(exception)-1] == '\n')
992 0 0 for(cxix = cxstack_ix; cxix; cxix--) {
993 0 0 if(CxTYPE(&cxstack[cxix]) != CXt_SUB)
997 0 0 if(!cv)
1000 0 0 const char *stashname = HvNAME(CvSTASH(cv));
0 0 const char *stashname = HvNAME(CvSTASH(cv));
0 0 const char *stashname = HvNAME(CvSTASH(cv));
0 0 const char *stashname = HvNAME(CvSTASH(cv));
0 0 const char *stashname = HvNAME(CvSTASH(cv));
0 0 const char *stashname = HvNAME(CvSTASH(cv));
1001 0 0 if(!stashname)
1005 0 0 if(strEQ(stashname, "Future::_base"))
1008 0 0 const COP *cop = cxix < cxstack_ix ? cxstack[cxix+1].blk_oldcop : PL_curcop;
1010 0 0 sv_catpvf(exception, " at %s line %d.\n", CopFILE(cop), CopLINE(cop));
1018 0 0 if(self->cancelled)
1022 0 0 if(!self->result)
1032 0 0 if(!self->ready)
1035 0 0 if(!self->failure)
1045 0 0 if(self->ready)
1051 0 0 if(self->subs) {
1052 0 0 for(Size_t i = 0; i < av_count(self->subs); i++)
0 0 for(Size_t i = 0; i < av_count(self->subs); i++)
1059 0 0 for(int i = on_cancel ? AvFILL(on_cancel) : -1; i >= 0; i--) {
0 0 for(int i = on_cancel ? AvFILL(on_cancel) : -1; i >= 0; i--) {
0 0 for(int i = on_cancel ? AvFILL(on_cancel) : -1; i >= 0; i--) {
1061 0 0 if(!SvOK(code))
0 0 if(!SvOK(code))
0 0 if(!SvOK(code))
1064 0 0 if(sv_is_future(code)) {
1070 0 0 PUSHMARK(SP);
1076 0 0 FREETMPS;
1085 0 0 PUSHMARK(SP);
1092 0 0 FREETMPS;
1122 0 0 if(flags & FUTURE_THEN_WITH_F)
1147 0 0 if(flags & FUTURE_THEN_WITH_F)
1162 0 0 for(Size_t i = 0; i < n; i++) {
1163 0 0 if(!SvROK(subs[i]) || !SvOBJECT(SvRV(subs[i])))
0 0 if(!SvROK(subs[i]) || !SvOBJECT(SvRV(subs[i])))
1166 0 0 if(SvSTASH(SvRV(subs[i])) != future_stash) {
1172 0 0 SV *f = proto ? future_new_proto(proto) : future_new(cls);
1175 0 0 if(!self->subs)
1178 0 0 for(Size_t i = 0; i < n; i++)
1193 0 0 if(srcself->failure) {
1194 0 0 self->failure = newAV_svn_dup(AvARRAY(srcself->failure), av_count(srcself->failure));
1198 0 0 self->result = newAV_svn_dup(AvARRAY(srcself->result), av_count(srcself->result));
1205 0 0 if(!self->subs)
1208 0 0 for(Size_t i = 0; i < av_count(self->subs); i++) {
0 0 for(Size_t i = 0; i < av_count(self->subs); i++) {
1210 0 0 if(!future_is_ready(sub))
1220 0 0 if(!SvOK(f))
0 0 if(!SvOK(f))
0 0 if(!SvOK(f))
1231 0 0 if(self->pending_subs)
1235 0 0 self->result = newAV_svn_dup(AvARRAY(self->subs), av_count(self->subs));
1245 0 0 for(Size_t i = 0; i < n; i++) {
1247 0 0 if(!future_is_ready(subs[i]))
1251 0 0 if(!self->pending_subs) {
1266 0 0 for(Size_t i = 0; i < n; i++) {
1267 0 0 if(!future_is_ready(subs[i]))
1282 0 0 if(!SvOK(f))
0 0 if(!SvOK(f))
0 0 if(!SvOK(f))
1291 0 0 if(self->result || self->failure)
0 0 if(self->result || self->failure)
1298 0 0 if(self->pending_subs && this_cancelled)
0 0 if(self->pending_subs && this_cancelled)
1301 0 0 if(this_cancelled) {
1318 0 0 if(!n) {
1324 0 0 for(Size_t i = 0; i < n; i++) {
1326 0 0 if(future_is_ready(subs[i]) && !future_is_cancelled(subs[i])) {
0 0 if(future_is_ready(subs[i]) && !future_is_cancelled(subs[i])) {
1332 0 0 if(immediate_ready) {
1352 0 0 for(Size_t i = 0; i < n; i++) {
1353 0 0 if(future_is_cancelled(subs[i]))
1369 0 0 for(Size_t i = 0; i < av_count(self->subs); i++) {
0 0 for(Size_t i = 0; i < av_count(self->subs); i++) {
1373 0 0 av_push_svn(result, AvARRAY(subself->result), av_count(subself->result));
1383 0 0 if(!SvOK(f))
0 0 if(!SvOK(f))
0 0 if(!SvOK(f))
1392 0 0 if(self->result || self->failure)
0 0 if(self->result || self->failure)
1395 0 0 if(future_is_cancelled(thissub)) {
1400 0 0 else if(future_is_failed(thissub)) {
1407 0 0 if(self->pending_subs)
1419 0 0 if(!n) {
1425 0 0 for(Size_t i = 0; i < n; i++) {
1426 0 0 if(future_is_cancelled(subs[i])) {
1431 0 0 if(future_is_failed(subs[i])) {
1437 0 0 if(immediate_fail) {
1454 0 0 for(Size_t i = 0; i < n; i++) {
1455 0 0 if(future_is_ready(subs[i]))
1462 0 0 if(!self->pending_subs) {
1478 0 0 if(!SvOK(f))
0 0 if(!SvOK(f))
0 0 if(!SvOK(f))
1487 0 0 if(self->result || self->failure)
0 0 if(self->result || self->failure)
1494 0 0 if(self->pending_subs && this_cancelled)
0 0 if(self->pending_subs && this_cancelled)
1497 0 0 if(this_cancelled) {
1500 0 0 else if(future_is_failed(thissub)) {
1501 0 0 if(self->pending_subs)
1519 0 0 if(!n) {
1525 0 0 for(Size_t i = 0; i < n; i++) {
1526 0 0 if(future_is_done(subs[i])) {
1532 0 0 if(immediate_done) {
1549 0 0 for(Size_t i = 0; i < n; i++) {
1550 0 0 if(future_is_ready(subs[i]))
1557 0 0 if(!self->pending_subs) {
1574 0 0 for(Size_t i = 0; self->subs && i < av_count(self->subs); i++) {
0 0 for(Size_t i = 0; self->subs && i < av_count(self->subs); i++) {
0 0 for(Size_t i = 0; self->subs && i < av_count(self->subs); i++) {
1600 0 0 if(want) {
1601 0 0 XPUSHs(sv_mortalcopy(sub));
1626 0 0 if(self->label)
1643 0 0 if(!self->udata)
1653 0 0 if(!self->udata)
1657 0 0 return he ? HeVAL(he) : &PL_sv_undef;
1744 0 4 if(!val || !val[0])
0 0 if(!val || !val[0])
1746 0 0 if(val[0] == '0' && strlen(val) == 1)
0 0 if(val[0] == '0' && strlen(val) == 1)
1759 2 0 capture_times = future_debug || getenv_bool("PERL_FUTURE_TIMES");
0 2 capture_times = future_debug || getenv_bool("PERL_FUTURE_TIMES");
1760 0 2 sv_setsv(get_sv("Future::TIMES", GV_ADDMULTI), capture_times ? &PL_sv_yes : &PL_sv_no);
1772 0 2 newCONSTSUB(gv_stashpvn("Future::XS", 10, TRUE), "DEBUG", newSVbool(future_debug));