|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public static interface ForkJoinPool.ManagedBlocker
Disabled: no SafeJ information.
Interface for extending managed parallelism for tasks running
in ForkJoinPool
s.
A ManagedBlocker
provides two methods.
Method isReleasable
must return true
if
blocking is not necessary. Method block
blocks the
current thread if necessary (perhaps internally invoking
isReleasable
before actually blocking).
For example, here is a ManagedBlocker based on a ReentrantLock:
class ManagedLocker implements ManagedBlocker {
final ReentrantLock lock;
boolean hasLock = false;
ManagedLocker(ReentrantLock lock) { this.lock = lock; }
public boolean block() {
if (!hasLock)
lock.lock();
return true;
}
public boolean isReleasable() {
return hasLock || (hasLock = lock.tryLock());
}
}
Method Summary | |
---|---|
boolean |
block()
Possibly blocks the current thread, for example waiting for a lock or condition. |
boolean |
isReleasable()
Returns true if blocking is unnecessary. |
Method Detail |
---|
boolean block() throws InterruptedException
true
if no additional blocking is necessary
(i.e., if isReleasable would return true)
InterruptedException
- if interrupted while waiting
(the method is not required to do so, but is allowed to)boolean isReleasable()
true
if blocking is unnecessary.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |