Skip to content

Callback tryOnSuccess/tryOnFailure#971

Merged
Avasil merged 21 commits into
monix:masterfrom
alexandru:callback-try
Aug 8, 2019
Merged

Callback tryOnSuccess/tryOnFailure#971
Avasil merged 21 commits into
monix:masterfrom
alexandru:callback-try

Conversation

@alexandru
Copy link
Copy Markdown
Member

This is a continuation of #917.

Thread-safe implementations of Callback (that protect the Callback's contract) are supposed to throw CallbackCalledMultipleTimesException in case the result was signaled more than once.

The callbacks returned the Callback.safe, Callback.trampoline and Callback.forked wrappers are now all thread-safe. The callback injected in Task.create (and variants) is thread-safe as well.

Also added 2 methods on Callback: tryOnSuccess and tryOnFailure. These forward by default the call to onSuccess and onError. If these throw, then the exception gets caught in the try* versions.

Comment thread monix-eval/shared/src/main/scala/monix/eval/internal/TaskShift.scala Outdated
@alexandru
Copy link
Copy Markdown
Member Author

This one is ready for merging.

I added tests and changed the behavior of the Task.async builders to also report errors, thrown in the registration function, via the callback. We couldn't do that before because the callback wasn't safe.

@Avasil
Copy link
Copy Markdown
Collaborator

Avasil commented Aug 3, 2019

Thanks @alexandru , we'll get it in for the release

@Avasil Avasil added this to the 3.0.0 milestone Aug 6, 2019
@Avasil
Copy link
Copy Markdown
Collaborator

Avasil commented Aug 8, 2019

I'm merging it @oleg-py but if you have any objections/suggestions we can patch it in next PR

@Avasil Avasil merged commit ada76d5 into monix:master Aug 8, 2019
mdedetrich pushed a commit to mdedetrich/monix that referenced this pull request Mar 28, 2020
* Callback tryOnSuccess/tryOnFailure

* Callback safety and tests

* Hide protectedCallback

* Fix doOnCancel

* Fix callback in TaskCreate

* Add test for popping the connection

* Docs, tests

* Docs

* Cleanup

* More try methods

* More tests

* More tests for Task.create

* More fixes, more tests

* Simplification

* Formatting

* Address review

* Fix compilation for 2.11

* Nulify error

* Refactoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants