File tree Expand file tree Collapse file tree 2 files changed +51
-8
lines changed
java8/src/main/java/org/jetbrains/annotations Expand file tree Collapse file tree 2 files changed +51
-8
lines changed Original file line number Diff line number Diff line change 22
22
* Indicates that the annotated executor (e.g. coroutine dispatcher, scheduler, etc.)
23
23
* allows blocking methods execution.
24
24
*
25
- * If a given context does not allow blocking calls, {@link NonBlockingExecutor} should be used.
25
+ * If a given executor does not allow blocking calls, {@link NonBlockingExecutor} should be used.
26
26
*
27
- * Example:
27
+ * Example 1 (Kotlin coroutines) :
28
28
* <pre>
29
29
* {@code
30
- * class ExampleService {
31
- * @BlockingContext
30
+ * class BlockingExampleService {
31
+ * @BlockingExecutor
32
32
* val dispatcher: CoroutineContext
33
33
* get() { ... }
34
34
*
42
42
* }
43
43
* }
44
44
* </pre>
45
+ *
46
+ * Example 2 (Java with Reactor framework):
47
+ * <pre>
48
+ * {@code
49
+ * class BlockingExampleService {
50
+ * private static final @BlockingExecutor Scheduler blockingScheduler =
51
+ * Schedulers.newBoundedElastic(4, 10, "executor");
52
+ *
53
+ * public Flux<String> foo(Flux<String> urls) {
54
+ * return urls.publishOn(blockingScheduler)
55
+ * .map(url -> blockingBuzz(url)); // no IDE warning
56
+ * }
57
+ *
58
+ * @Blocking
59
+ * private String blockingBuzz(String url) { ... }
60
+ * }
61
+ * }
62
+ * </pre>
63
+ *
64
+ * @see Blocking
65
+ * @see NonBlocking
45
66
*/
46
67
@ Documented
47
68
@ Retention (RetentionPolicy .CLASS )
Original file line number Diff line number Diff line change 22
22
* Indicates that the annotated executor (e.g. coroutine dispatcher, scheduler, etc.)
23
23
* does not allow blocking methods execution.
24
24
*
25
- * If a given context allows blocking calls, {@link BlockingExecutor} should be used.
25
+ * If a given executor allows blocking calls, {@link BlockingExecutor} should be used.
26
26
*
27
- * Example:
27
+ * Example 1 (Kotlin coroutines) :
28
28
* <pre>
29
29
* {@code
30
- * class ExampleService {
31
- * @NonBlockingContext
30
+ * class NonBlockingExampleService {
31
+ * @NonBlockingExecutor
32
32
* val dispatcher: CoroutineContext
33
33
* get() { ... }
34
34
*
42
42
* }
43
43
* }
44
44
* </pre>
45
+ *
46
+ * <br>
47
+ * Example 2 (Java with Reactor framework):
48
+ * <pre>
49
+ * {@code
50
+ * class NonBlockingExampleService {
51
+ * private static final @NonBlockingExecutor Scheduler operationsScheduler =
52
+ * Schedulers.newParallel("parallel");
53
+ *
54
+ * public Flux<String> foo(Flux<String> urls) {
55
+ * return urls.publishOn(operationsScheduler)
56
+ * .filter(url -> blockingBuzz(url) != null); // IDE warning: `Possibly blocking call in non-blocking context`
57
+ * }
58
+ *
59
+ * @Blocking
60
+ * private String blockingBuzz(String url) { ... }
61
+ * }
62
+ * }
63
+ * </pre>
64
+ *
65
+ * @see Blocking
66
+ * @see NonBlocking
45
67
*/
46
68
@ Documented
47
69
@ Retention (RetentionPolicy .CLASS )
You can’t perform that action at this time.
0 commit comments