org.jikesrvm.scheduler
Class RVMThread.BlockAdapter

java.lang.Object
  extended by org.jikesrvm.scheduler.RVMThread.BlockAdapter
Direct Known Subclasses:
RVMThread.GCBlockAdapter, RVMThread.HandshakeBlockAdapter, RVMThread.SuspendBlockAdapter
Enclosing class:
RVMThread

public abstract static class RVMThread.BlockAdapter
extends Object

A block adapter specifies the reason for blocking or unblocking a thread. A thread remains blocked so long as any of the block adapters say that it should be blocked. Block adapters are statically allocated, and store their state in instance fields of RVMThread.


Constructor Summary
RVMThread.BlockAdapter()
           
 
Method Summary
(package private) abstract  void clearBlockRequest(RVMThread t)
          Clear any blocking requests.
(package private) abstract  boolean hasBlockRequest(RVMThread t)
          Does the thread have a request to block for this block adapter?
(package private) abstract  boolean hasBlockRequest(RVMThread t, int token)
          Does the thread have a request to block associated with the given requestBlock() call?
(package private) abstract  boolean isBlocked(RVMThread t)
          Should the given thread be blocked for this block adapter?
(package private) abstract  int requestBlock(RVMThread t)
          Request that the thread block, for this block adapter, at its earliest convenience.
(package private) abstract  void setBlocked(RVMThread t, boolean value)
          Specify that the thread is either blocked (value == true) or not blocked (value == false) for this block adapter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RVMThread.BlockAdapter

public RVMThread.BlockAdapter()
Method Detail

isBlocked

abstract boolean isBlocked(RVMThread t)
Should the given thread be blocked for this block adapter? If this returns true, the thread is guaranteed to block.


setBlocked

abstract void setBlocked(RVMThread t,
                         boolean value)
Specify that the thread is either blocked (value == true) or not blocked (value == false) for this block adapter. This call indicates a statement of fact by the thread itself - it's used either to acknowledge a block request (see hasBlockRequest below) or to respond to a request to unblock.


requestBlock

abstract int requestBlock(RVMThread t)
Request that the thread block, for this block adapter, at its earliest convenience. Called from RVMThread.block() and associated methods. Some block adapters allow for multiple requests to block; in that case this will return a "token" that can be passed to hasBlockRequest() to check, not only whether there is a block request, but whether that block request is still associated with a particular call to requestBlock(). This is used to prevent a suspend() call from stalling due to a concurrent resume() and second suspend(). Note that most block adapers don't care about this scenario, and will just return 0 (or some other meaningless number) here.


hasBlockRequest

abstract boolean hasBlockRequest(RVMThread t)
Does the thread have a request to block for this block adapter?


hasBlockRequest

abstract boolean hasBlockRequest(RVMThread t,
                                 int token)
Does the thread have a request to block associated with the given requestBlock() call?


clearBlockRequest

abstract void clearBlockRequest(RVMThread t)
Clear any blocking requests.