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

Add dynamic predicate support (Kotlin, Scala, others) #72

Merged
merged 3 commits into from
Jan 23, 2020

Conversation

bsideup
Copy link
Contributor

@bsideup bsideup commented Nov 25, 2019

At S1P, we discussed with @elizarov the possibility of adding BlockHound integration to Kotlin:
Kotlin/kotlinx.coroutines#1031

One of the major blockers was a lack of an API to dynamically decide whether thread is blocking or non-blocking since, in Kotlin, they change it dynamically.

This PR adds a new API to mark thread as "dynamic", which means that the blocking check should call threadPredicate once again before reporting the blocking call.

Example usage:

b.aaDynamicThreadPredicate(DynamicThread.class::isInstance);

b.nonBlockingThreadPredicate(p -> p.or(thread -> {
    return thread instanceof DynamicThread && ((DynamicThread) thread).isNonBlocking;
}));

where DynamicThread#isNonBlocking is a field that reflects the current "mode".

@bsideup bsideup added this to the next milestone Nov 25, 2019
@bsideup
Copy link
Contributor Author

bsideup commented Nov 25, 2019

@elizarov could you please take a look at this new API and tell us if this will be sufficient for Kotlin? Thanks!

@elizarov
Copy link

@elizarov could you please take a look at this new API and tell us if this will be sufficient for Kotlin? Thanks!

Looks good to me!

@bsideup bsideup marked this pull request as ready for review January 22, 2020 13:25
@bsideup bsideup merged commit 091d7b1 into master Jan 23, 2020
@bsideup bsideup linked an issue Feb 5, 2020 that may be closed by this pull request
@bsideup bsideup mentioned this pull request Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamic predicates
2 participants