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

Improve correctness of Future.hook #238

Merged
merged 1 commit into from
May 10, 2018
Merged

Improve correctness of Future.hook #238

merged 1 commit into from
May 10, 2018

Conversation

Avaq
Copy link
Member

@Avaq Avaq commented Apr 6, 2018

This PR introduces two significant changes to how Hook works:

  1. The cancellation signal is never sent down to the disposal Future anymore. If cancellation happens, disposal is allowed to complete, but its results are ignored. Closes Make dispose in Hook uncancellable #234.
  2. When an exception occurs during consumption, the disposal Future still runs, similarly to what happens when the consumption Future is cancelled. This was not considered while exception recovery was being implemented. Now that exception recovery exists, we should allow resources to be disposed (we no longer assume to process to crash).

I've tried to explain these semantics in the README.

@safareli I've asked you for a review because this change affects semantics and is partly inspired by PureScript Aff.

Ping @syaiful6 because you were the person to bring this to my attention.

@Avaq Avaq added the breaking label Apr 6, 2018
@Avaq Avaq requested a review from safareli April 6, 2018 09:43
@codecov-io
Copy link

codecov-io commented Apr 6, 2018

Codecov Report

Merging #238 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #238   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          48     48           
  Lines        1187   1196    +9     
=====================================
+ Hits         1187   1196    +9
Impacted Files Coverage Δ
src/hook.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2d890ec...f807a3f. Read the comment docs.

In the case where the consumption Future settles, the disposal is forked and
awaited. If the disposal Future rejects or encounters an exception, it will
replace the state of the consumption Future. Otherwise the rejection reason or
resolution value of the consumption Future will determine the final outcome.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is “consumption” being used as an adjective here? This doesn't sound right to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to quick way to refer to "the Future returned by the consume function".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

Copy link

@safareli safareli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I can't do the review in close future :(

@Avaq
Copy link
Member Author

Avaq commented Apr 13, 2018

I can't do the review in close future :(

Alright, no worries!

@Avaq Avaq merged commit 5bbe28b into master May 10, 2018
@Avaq Avaq deleted the avaq/hook-correctness branch May 10, 2018 11:29
Avaq added a commit that referenced this pull request Jul 26, 2018
Breaking changes

- #224 Exceptions are now caught and rethrown in `fork`.
- #230 Many of the TypeScript type definitions that used `never` now use a
  generic instead.
- #238 When unsubscribing from a Future created by `hook`, the cancellation
  signal is no longer sent to the disposal Future.
- #266 Exported TypeScript interfaces have been renamed to avoid naming
  conflicts with exported values.

New features

- #250 Included interoperability with Sanctuary Show
- #261 Added a new function, `forkCatch`, which allows for exception recovery.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants