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

BlockHound integration #1821

Merged
merged 15 commits into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Document BlockHound integration better
  • Loading branch information
dkhalanskyjb committed Mar 16, 2020
commit e16face08c7c3c548b758ce1d3d23131c770bc35
12 changes: 12 additions & 0 deletions kotlinx-coroutines-core/jvm/src/scheduling/CoroutineScheduler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -952,10 +952,22 @@ internal class CoroutineScheduler(
}
}

/**
* Checks if the thread is part of a thread pool that supports coroutines.
*
* This function is needed for integration with BlockHound and accessed by violating the
* visibility modifier.
*/
@Suppress("UNUSED")
@JvmName("isSchedulerWorker")
internal fun isSchedulerWorker(thread: Thread) = thread is CoroutineScheduler.Worker
qwwdfsad marked this conversation as resolved.
Show resolved Hide resolved

/**
* Checks if the thread is running a CPU-bound task.
*
* This function is needed for integration with BlockHound and accessed by violating the
* visibility modifier.
*/
@Suppress("UNUSED")
@JvmName("mayNotBlock")
internal fun mayNotBlock(thread: Thread) = thread is CoroutineScheduler.Worker &&
Expand Down
3 changes: 3 additions & 0 deletions kotlinx-coroutines-debug/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ suspension stacktraces.
Additionally, it is possible to process the list of such coroutines via [DebugProbes.dumpCoroutinesInfo] or dump isolated parts
of coroutines hierarchy referenced by a [Job] or [CoroutineScope] instances using [DebugProbes.printJob] and [DebugProbes.printScope] respectively.

Additionally, this module provides a [BlockHound](https://github.com/reactor/BlockHound) service
that detects when a blocking operation was called in a coroutine context that prohibits it.

### Using in your project

Add `kotlinx-coroutines-debug` to your project test dependencies:
Expand Down