Top Description Methods
org.jetbrains.annotations

public @Interface NonBlockingExecutor

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

Indicates that the annotated executor (CoroutineContext, Scheduler) does not allow blocking methods execution.

If a given executor allows blocking calls, BlockingExecutor should be used.

Example 1 (Kotlin coroutines):


 class NonBlockingExampleService {
     val dispatcher: @NonBlockingExecutor CoroutineContext
         get() { ... }

     suspend fun foo() {
         val result = withContext(dispatcher) {
             blockingBuzz() // IDE warning: `Possibly blocking call in non-blocking context`
         }
     }

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

Example 2 (Java with Reactor framework):


 class NonBlockingExampleService {
     private static final @NonBlockingExecutor Scheduler operationsScheduler =
             Schedulers.newParallel("parallel");

     public Flux<String> foo(Flux<String> urls) {
         return urls.publishOn(operationsScheduler)
                 .filter(url -> blockingBuzz(url) != null);  // IDE warning: `Possibly blocking call in non-blocking context`
     }

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

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString