Top Description Methods
org.jetbrains.annotations

public @Interface BlockingExecutor

extends Annotation
Annotations
@Documented
@Retention:CLASS
@Target:TYPE, TYPE_USE
Imports
java.lang.annotation.*

Indicates that the annotated executor (CoroutineContext, Scheduler) allows blocking methods execution.

If a given executor does not allow blocking calls, NonBlockingExecutor should be used.

Example 1 (Kotlin coroutines):


 class BlockingExampleService {
     val dispatcher: @BlockingExecutor CoroutineContext
         get() { ... }

     suspend fun foo() {
         val result = withContext(dispatcher) {
             blockingBuzz() // no IDE warning
         }
     }

     @Blocking fun blockingBuzz() { ... }
 }

Example 2 (Java with Reactor framework):


class BlockingExampleService {
    private static final @BlockingExecutor Scheduler blockingScheduler =
            Schedulers.newBoundedElastic(4, 10, "executor");

    public Flux<String> foo(Flux<String> urls) {
        return urls.publishOn(blockingScheduler)
                .map(url -> blockingBuzz(url));  // no IDE warning
    }

    @Blocking
    private String blockingBuzz(String url) { ... }
}
See Also
Blocking, NonBlocking

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString