Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding a way to register explicit on-terminate callbacks from within a coroutine. #64

Closed
jmalloc opened this issue Jan 3, 2014 · 1 comment
Milestone

Comments

@jmalloc
Copy link
Member

jmalloc commented Jan 3, 2014

Because there is no way to force-close a generator, finally blocks can not (necessarily) be relied upon for deterministic execution.

$coroutine = function () {
   yield Recoil::onTerminate(function () { });
};

The callback would be called if the coroutine ticks after terminateOnNextTick() has been called, rather than attaching a handler directly to the strand's terminate event.

Something like this may allow some of the kernel API to be implemented more concisely as coroutines.

@jmalloc
Copy link
Member Author

jmalloc commented Jan 3, 2014

Could also be implemented as:

$coroutine = function () {
  yield Recoil::finally_(function ($exception) {});
}

Where $exception is set to the exception that is causing the stack unwind, or StrandTerminateException on termination. The exception would be null if the coroutine returned a value normally.

@jmalloc jmalloc closed this as completed in 072715b Jan 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant