Allow registering a custom Predicate for determining non-blocking threads#3854
Merged
chemicL merged 3 commits intoreactor:3.6.xfrom Jul 23, 2024
Merged
Conversation
…hreads Related issue: reactor#3833 Motivation: It is currently not possible to create a non-blocking threads without implementing the `reactor.core.scheduler.NonBlocking` interface. Some third-party libraries and frameworks don't directly depend on `reactor-core`, yet they want to mark the threads they manage as non-blocking. Modifications: - Added a new method `Schedulers.registerNonBlockingThreadPredicate()` so that a user can register their own `Predicate` that determines whether a given thread is non-blocking or not - Also added `Schedulers.resetNonBlockingThreadPredicate()` so that a user can unregister all previous `Predicate`s - Fixed an incorrectly implemented test that doesn't really test anything: - `SchedulersTest.isInNonBlockingThreadTrue()` Result: - Closes reactor#3833 - A user can now mark their own `Thread` classes as non-blocking without depending on `reactor-core` or implementing the `NonBlocking` marker interface.
Member
|
Please run |
Contributor
Author
|
@chemicL It looks like 3.6.x doesn't have Spotless. I can update the license headers of the modified files, but could you point me to the right license header? |
Contributor
Author
|
By the way, I ran Environment: |
Member
|
I'm not sure what's up with your local setup, but there's nothing fishy on our side I think. I will commit my updates and we can merge. Here's what I did: And running |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue: #3833
Motivation:
It is currently not possible to create a non-blocking threads without implementing the
reactor.core.scheduler.NonBlockinginterface. Some third-party libraries and frameworks don't directly depend onreactor-core, yet they want to mark the threads they manage as non-blocking.Modifications:
Schedulers.registerNonBlockingThreadPredicate()so that a user can register their ownPredicatethat determines whether a given thread is non-blocking or notSchedulers.resetNonBlockingThreadPredicate()so that a user can unregister all previousPredicatesSchedulersTest.isInNonBlockingThreadTrue()Result:
Threadclasses as non-blocking without depending onreactor-coreor implementing theNonBlockingmarker interface.