Package org.jetbrains.annotations

# Annotation Interface BlockingExecutor

@Documented @Retention(CLASS) @Target({TYPE,TYPE_USE}) public @interface BlockingExecutor
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`