|
JanosVM v1.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.utah.janosvm.sys.TeamReservation
Record a reservation with another team. A TeamReservation is a
link between two teams that prevents either from being terminated.
A TeamReservation is more flexible than TeamHandle.switchTo()
, as the termination-delaying time can be
expanded to include more than the context switch to the other team.
While an active reservation delays termination of two teams,
there are two conditions that can cause a TeamEjectionException
during a visit:
Object.wait()
.
If a thread blocks on Object.wait, that will re-enable
termination of the Teams involved. If the team is terminated
during a wait, an exception will be thrown to back the
thread out of the visit. (Most likely a TeamEjectionException
.)
If a thread tries to allocate memory during a visit, and the current Team has reached its memory limits, the allocation will throw a TeamEjectionException. This exception may also occur during a throw statement. In all cases, such an exception implies that the visited Team will be terminated.
XXX need something about inter-Team pointers and how to be
careful Object.clone()
, etc...
CAUTION: TeamReservation's must be created and popped at
the same scope. Ideally, there would be language support for
TeamReservations that works like synchronized
does for
restricting monitor lock/unlock to the same scope. Of course, you should
always use visit/leave in pairs, inside the push/pop, and you shouldn't
use the TeamReservation after a pop.
Here's an example:
try { TeamReservation resv; Object obj; resv =otherTeam.pushReservation
(); resv.visit
(); // Do things in the context of 'otherTeam' obj = lookupSimpleFoo(); resv.leave
(); // Do things in original context, but guarantee that // otherTeam will not go away ... Reservation still active. Object localObj = new Foo(obj); // End the Reservation, as we're done with all pointers into otherTeam // (Assuming the Foo constructor didn't do anything stupid.) resv.pop
(); } catch (DeadTeamException
e) { // pushReservation failed } catch (TeamEjectionException
e) { // allocation/throw failed during visit }
TeamHandle.pushReservation()
,
Team#popReservation()
,
TeamHandle.switchTo()
Constructor Summary | |
private |
TeamReservation()
Hide the constructor. |
Method Summary | |
static void |
leave()
Return to the previous team. |
void |
pop()
Pop this TeamReservation off the stack. |
java.lang.String |
toString()
|
void |
visit()
Switch the current thread to the team encoded in this Reservation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait, wait0 |
Constructor Detail |
private TeamReservation()
Team.pushReservation()
.TeamHandle.pushReservation()
Method Detail |
public void visit() throws TeamEjectionException
leave()
public static void leave()
visit()
public void pop()
public java.lang.String toString()
toString
in class java.lang.Object
|
JanosVM v1.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |