|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.asyncobjects.vats.Vat
public class Vat
Vat is managed collection of objects. Mapping between vats and threads is
generally speaking dynamic and is provide by VatRunner
.
Nested Class Summary | |
---|---|
protected static class |
Vat.VatState
Vat state |
Field Summary | |
---|---|
protected Object |
attachmentLock
a lock for detach/attache operations |
protected Semaphore |
detach
a semaphore for detach process, guared by state lock |
protected Vat.VatState |
state
state of vat, guarded by state lock |
protected Object |
stateLock
state lock |
protected Object |
ticket
a running ticket, guarded by state lock |
Constructor Summary | |
---|---|
Vat()
a constructor |
|
Vat(String name)
a constructor |
|
Vat(VatRunner runner)
a constructor |
|
Vat(VatRunner runner,
String name)
a constructor |
Method Summary | |
---|---|
void |
attachToRunner(VatRunner newRunner)
Attach to runner |
static Vat |
current()
Current vat for current thread. |
void |
detachFromRunner(boolean waitForIt)
Detach from runner. |
int |
dispatchEventBatch(int n)
Dispatch events without setting context |
int |
dispatchVatEvents(Object ticket,
int n)
Dispatch at most n events for the vat. |
void |
enqueue(Runnable r)
enqueue runnuable |
static String |
generateVatName(Class<?> c)
Generate vat name |
String |
getName()
get vat name |
VatRunner |
getRunner()
|
boolean |
hasEvents()
|
boolean |
isDetached()
|
static void |
offerSensor(Class cls)
Offer sensor to vat |
protected void |
resetCurrentVat()
Disassociate thread from vat |
VatRunner |
runner()
|
protected boolean |
setCurrentVat(Object queueTicket)
Associate this thread with this vat |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Vat.VatState state
protected Object stateLock
protected Object ticket
protected Object attachmentLock
protected Semaphore detach
Constructor Detail |
---|
public Vat(VatRunner runner, String name)
runner
- a vat runnername
- name of vatpublic Vat(VatRunner runner)
runner
- a vat runnerpublic Vat(String name)
name
- name of vatpublic Vat()
Method Detail |
---|
public static String generateVatName(Class<?> c)
c
- a class
public boolean isDetached()
public void detachFromRunner(boolean waitForIt) throws InterruptedException
waitForIt
- if true, the method does not returns until vat
InterruptedException
- operation was interrupted, detach process is possibly
incompletepublic VatRunner runner()
public void attachToRunner(VatRunner newRunner)
newRunner
- a new runner for the vatpublic String getName()
public static Vat current()
protected boolean setCurrentVat(Object queueTicket)
queueTicket
- a ticket with which vat was enqueued
protected void resetCurrentVat()
public void enqueue(Runnable r)
r
- runnable to enqueuepublic boolean hasEvents()
public int dispatchVatEvents(Object ticket, int n)
ticket
- a ticket associated with eventsn
- an maximum amount of events to dispatch
public int dispatchEventBatch(int n)
n
- events to dispatcy
public static void offerSensor(Class cls)
cls
- a sensor classpublic VatRunner getRunner()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |