3252 |
|
} |
3253 |
|
|
3254 |
|
/** |
3255 |
< |
* Blocks in accord with the given blocker. If the current thread |
3256 |
< |
* is a {@link ForkJoinWorkerThread}, this method possibly |
3257 |
< |
* arranges for a spare thread to be activated if necessary to |
3258 |
< |
* ensure sufficient parallelism while the current thread is blocked. |
3255 |
> |
* Runs the given possibly blocking task. When {@linkplain |
3256 |
> |
* ForkJoinTask#inForkJoinPool() running in a ForkJoinPool}, this |
3257 |
> |
* method possibly arranges for a spare thread to be activated if |
3258 |
> |
* necessary to ensure sufficient parallelism while the current |
3259 |
> |
* thread is blocked in {@link ManagedBlocker#block blocker.block()}. |
3260 |
|
* |
3261 |
< |
* <p>If the caller is not a {@link ForkJoinTask}, this method is |
3261 |
> |
* <p>This method repeatedly calls {@code blocker.isReleasable()} and |
3262 |
> |
* {@code blocker.block()} until either method returns {@code true}. |
3263 |
> |
* Every call to {@code blocker.block()} is preceded by a call to |
3264 |
> |
* {@code blocker.isReleasable()} that returned {@code false}. |
3265 |
> |
* |
3266 |
> |
* <p>If not running in a ForkJoinPool, this method is |
3267 |
|
* behaviorally equivalent to |
3268 |
|
* <pre> {@code |
3269 |
|
* while (!blocker.isReleasable()) |
3270 |
|
* if (blocker.block()) |
3271 |
< |
* return;}</pre> |
3271 |
> |
* break;}</pre> |
3272 |
|
* |
3273 |
< |
* If the caller is a {@code ForkJoinTask}, then the pool may |
3274 |
< |
* first be expanded to ensure parallelism, and later adjusted. |
3273 |
> |
* If running in a ForkJoinPool, the pool may first be expanded to |
3274 |
> |
* ensure sufficient parallelism available during the call to |
3275 |
> |
* {@code blocker.block()}. |
3276 |
|
* |
3277 |
< |
* @param blocker the blocker |
3278 |
< |
* @throws InterruptedException if blocker.block did so |
3277 |
> |
* @param blocker the blocker task |
3278 |
> |
* @throws InterruptedException if {@code blocker.block()} did so |
3279 |
|
*/ |
3280 |
|
public static void managedBlock(ManagedBlocker blocker) |
3281 |
|
throws InterruptedException { |