AnyEvent-XSPromises

 view release on metacpan or  search on metacpan

XSPromises.xs  view on Meta::CPAN

    CODE:
        xspr_promise_decref(aTHX_ self->promise);
        Safefree(self);


MODULE = AnyEvent::XSPromises     PACKAGE = AnyEvent::XSPromises::PromisePtr

void
then(self, ...)
        AnyEvent::XSPromises::Promise* self
    PPCODE:
        SV* on_resolve;
        SV* on_reject;
        xspr_promise_t* next = NULL;

        if (items > 3) {
            croak_xs_usage(cv, "self, on_resolve, on_reject");
        }

        on_resolve = (items > 1) ? ST(1) : &PL_sv_undef;
        on_reject  = (items > 2) ? ST(2) : &PL_sv_undef;

XSPromises.xs  view on Meta::CPAN

        xspr_callback_t* callback = xspr_callback_new_perl(aTHX_ on_resolve, on_reject, next);
        xspr_promise_then(aTHX_ self->promise, callback);
        xspr_queue_maybe_schedule(aTHX);

        XSRETURN(1);

void
catch(self, on_reject)
        AnyEvent::XSPromises::Promise* self
        SV* on_reject
    PPCODE:
        xspr_promise_t* next = NULL;

        /* Many promises are just thrown away after the final callback, no need to allocate a next promise for those */
        if (GIMME_V != G_VOID) {
            AnyEvent__XSPromises__Promise* next_promise;
            Newxz(next_promise, 1, AnyEvent__XSPromises__Promise);

            next = xspr_promise_new(aTHX);
            next_promise->promise = next;

XSPromises.xs  view on Meta::CPAN

        xspr_callback_t* callback = xspr_callback_new_perl(aTHX_ &PL_sv_undef, on_reject, next);
        xspr_promise_then(aTHX_ self->promise, callback);
        xspr_queue_maybe_schedule(aTHX);

        XSRETURN(1);

void
finally(self, on_finally)
        AnyEvent::XSPromises::Promise* self
        SV* on_finally
    PPCODE:
        xspr_promise_t* next = NULL;

        /* Many promises are just thrown away after the final callback, no need to allocate a next promise for those */
        if (GIMME_V != G_VOID) {
            AnyEvent__XSPromises__Promise* next_promise;
            Newxz(next_promise, 1, AnyEvent__XSPromises__Promise);

            next = xspr_promise_new(aTHX);
            next_promise->promise = next;



( run in 0.516 second using v1.01-cache-2.11-cpan-71847e10f99 )