blob: 40dfb71195502ffebbed253e40fb1ff723873694 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.5.0_18) on Sun Apr 01 21:18:30 PDT 2012 -->
<TITLE>
CoroutineManager
</TITLE>
<META NAME="keywords" CONTENT="org.apache.xml.dtm.ref.CoroutineManager class">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
parent.document.title="CoroutineManager";
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/CoroutineManager.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../org/apache/xml/dtm/ref/ChunkedIntArray.ChunksVector.html" title="class in org.apache.xml.dtm.ref"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineParser.html" title="interface in org.apache.xml.dtm.ref"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?org/apache/xml/dtm/ref/CoroutineManager.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="CoroutineManager.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.apache.xml.dtm.ref</FONT>
<BR>
Class CoroutineManager</H2>
<PRE>
java.lang.Object
<IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.xml.dtm.ref.CoroutineManager</B>
</PRE>
<HR>
<DL>
<DT><PRE>public class <A HREF="../../../../../src-html/org/apache/xml/dtm/ref/CoroutineManager.html#line.106"><B>CoroutineManager</B></A><DT>extends java.lang.Object</DL>
</PRE>
<P>
<p>Support the coroutine design pattern.</p>
<p>A coroutine set is a very simple cooperative non-preemptive
multitasking model, where the switch from one task to another is
performed via an explicit request. Coroutines interact according to
the following rules:</p>
<ul>
<li>One coroutine in the set has control, which it retains until it
either exits or resumes another coroutine.</li>
<li>A coroutine is activated when it is resumed by some other coroutine
for the first time.</li>
<li>An active coroutine that gives up control by resuming another in
the set retains its context -- including call stack and local variables
-- so that if/when it is resumed, it will proceed from the point at which
it last gave up control.</li>
</ul>
<p>Coroutines can be thought of as falling somewhere between pipes and
subroutines. Like call/return, there is an explicit flow of control
from one coroutine to another. Like pipes, neither coroutine is
actually "in charge", and neither must exit in order to transfer
control to the other. </p>
<p>One classic application of coroutines is in compilers, where both
the parser and the lexer are maintaining complex state
information. The parser resumes the lexer to process incoming
characters into lexical tokens, and the lexer resumes the parser
when it has reached a point at which it has a reliably interpreted
set of tokens available for semantic processing. Structuring this
as call-and-return would require saving and restoring a
considerable amount of state each time. Structuring it as two tasks
connected by a queue may involve higher overhead (in systems which
can optimize the coroutine metaphor), isn't necessarily as clear in
intent, may have trouble handling cases where data flows in both
directions, and may not handle some of the more complex cases where
more than two coroutines are involved.</p>
<p>Most coroutine systems also provide a way to pass data between the
source and target of a resume operation; this is sometimes referred
to as "yielding" a value. Others rely on the fact that, since only
one member of a coroutine set is running at a time and does not
lose control until it chooses to do so, data structures may be
directly shared between them with only minimal precautions.</p>
<p>"Note: This should not be taken to mean that producer/consumer
problems should be always be done with coroutines." Queueing is
often a better solution when only two threads of execution are
involved and full two-way handshaking is not required. It's a bit
difficult to find short pedagogical examples that require
coroutines for a clear solution.</p>
<p>The fact that only one of a group of coroutines is running at a
time, and the control transfer between them is explicit, simplifies
their possible interactions, and in some implementations permits
them to be implemented more efficiently than general multitasking.
In some situations, coroutines can be compiled out entirely;
in others, they may only require a few instructions more than a
simple function call.</p>
<p>This version is built on top of standard Java threading, since
that's all we have available right now. It's been encapsulated for
code clarity and possible future optimization.</p>
<p>(Two possible approaches: wait-notify based and queue-based. Some
folks think that a one-item queue is a cleaner solution because it's
more abstract -- but since coroutine _is_ an abstraction I'm not really
worried about that; folks should be able to switch this code without
concern.)</p>
<p>%TBD% THIS SHOULD BE AN INTERFACE, to facilitate building other
implementations... perhaps including a true coroutine system
someday, rather than controlled threading. Arguably Coroutine
itself should be an interface much like Runnable, but I think that
can be built on top of this.</p>
<P>
<P>
<HR>
<P>
<!-- =========== FIELD SUMMARY =========== -->
<A NAME="field_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Field Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>(package private) static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineManager.html#ANYBODY">ANYBODY</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>(package private) &nbsp;java.util.BitSet</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineManager.html#m_activeIDs">m_activeIDs</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Is this coroutine ID number already in use" lookup table.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>(package private) &nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineManager.html#m_nextCoroutine">m_nextCoroutine</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Internal field used to confirm that the coroutine now waking up is
in fact the one we intended to resume.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>(package private) static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineManager.html#m_unreasonableId">m_unreasonableId</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Limit on the coroutine ID numbers accepted.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>(package private) &nbsp;java.lang.Object</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineManager.html#m_yield">m_yield</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Internal field used to hold the data being explicitly passed
from one coroutine to another during a co_resume() operation.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>(package private) static&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineManager.html#NOBODY">NOBODY</A></B></CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
</TABLE>
&nbsp;
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineManager.html#CoroutineManager()">CoroutineManager</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Object</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineManager.html#co_entry_pause(int)">co_entry_pause</A></B>(int&nbsp;thisCoroutine)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;In the standard coroutine architecture, coroutines are
identified by their method names and are launched and run up to
their first yield by simply resuming them; its's presumed that
this recognizes the not-already-running case and does the right
thing.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineManager.html#co_exit_to(java.lang.Object, int, int)">co_exit_to</A></B>(java.lang.Object&nbsp;arg_object,
int&nbsp;thisCoroutine,
int&nbsp;toCoroutine)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Make the ID available for reuse and terminate this coroutine,
transferring control to the specified coroutine.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineManager.html#co_exit(int)">co_exit</A></B>(int&nbsp;thisCoroutine)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Terminate this entire set of coroutines.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineManager.html#co_joinCoroutineSet(int)">co_joinCoroutineSet</A></B>(int&nbsp;coroutineID)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Each coroutine in the set managed by a single
CoroutineManager is identified by a small positive integer.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Object</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineManager.html#co_resume(java.lang.Object, int, int)">co_resume</A></B>(java.lang.Object&nbsp;arg_object,
int&nbsp;thisCoroutine,
int&nbsp;toCoroutine)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Transfer control to another coroutine which has already been started and
is waiting on this CoroutineManager.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ============ FIELD DETAIL =========== -->
<A NAME="field_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Field Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="m_activeIDs"><!-- --></A><H3>
m_activeIDs</H3>
<PRE>
java.util.BitSet <A HREF="../../../../../src-html/org/apache/xml/dtm/ref/CoroutineManager.html#line.113"><B>m_activeIDs</B></A></PRE>
<DL>
<DD>"Is this coroutine ID number already in use" lookup table.
Currently implemented as a bitset as a compromise between
compactness and speed of access, but obviously other solutions
could be applied.
<P>
<DL>
</DL>
</DL>
<HR>
<A NAME="m_unreasonableId"><!-- --></A><H3>
m_unreasonableId</H3>
<PRE>
static final int <A HREF="../../../../../src-html/org/apache/xml/dtm/ref/CoroutineManager.html#line.121"><B>m_unreasonableId</B></A></PRE>
<DL>
<DD>Limit on the coroutine ID numbers accepted. I didn't want the
in-use table to grow without bound. If we switch to a more efficient
sparse-array mechanism, it may be possible to raise or eliminate
this boundary.
<P>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#org.apache.xml.dtm.ref.CoroutineManager.m_unreasonableId">Constant Field Values</A></DL>
</DL>
<HR>
<A NAME="m_yield"><!-- --></A><H3>
m_yield</H3>
<PRE>
java.lang.Object <A HREF="../../../../../src-html/org/apache/xml/dtm/ref/CoroutineManager.html#line.149"><B>m_yield</B></A></PRE>
<DL>
<DD>Internal field used to hold the data being explicitly passed
from one coroutine to another during a co_resume() operation.
(Of course implicit data sharing may also occur; one of the reasons
for using coroutines is that you're guaranteed that none of the
other coroutines in your set are using shared structures at the time
you access them.)
%REVIEW% It's been proposed that we be able to pass types of data
other than Object -- more specific object types, or
lighter-weight primitives. This would seem to create a potential
explosion of "pass x recieve y back" methods (or require
fracturing resume into two calls, resume-other and
wait-to-be-resumed), and the weight issue could be managed by
reusing a mutable buffer object to contain the primitive
(remember that only one coroutine runs at a time, so once the
buffer's set it won't be walked on). Typechecking objects is
interesting from a code-robustness point of view, but it's
unclear whether it makes sense to encapsulate that in the
coroutine code or let the callers do it, since it depends on RTTI
either way. Restricting the parameters to objects implementing a
specific CoroutineParameter interface does _not_ seem to be a net
win; applications can do so if they want via front-end code, but
there seem to be too many use cases involving passing an existing
object type that you may not have the freedom to alter and may
not want to spend time wrapping another object around.
<P>
<DL>
</DL>
</DL>
<HR>
<A NAME="NOBODY"><!-- --></A><H3>
NOBODY</H3>
<PRE>
static final int <A HREF="../../../../../src-html/org/apache/xml/dtm/ref/CoroutineManager.html#line.152"><B>NOBODY</B></A></PRE>
<DL>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#org.apache.xml.dtm.ref.CoroutineManager.NOBODY">Constant Field Values</A></DL>
</DL>
<HR>
<A NAME="ANYBODY"><!-- --></A><H3>
ANYBODY</H3>
<PRE>
static final int <A HREF="../../../../../src-html/org/apache/xml/dtm/ref/CoroutineManager.html#line.153"><B>ANYBODY</B></A></PRE>
<DL>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#org.apache.xml.dtm.ref.CoroutineManager.ANYBODY">Constant Field Values</A></DL>
</DL>
<HR>
<A NAME="m_nextCoroutine"><!-- --></A><H3>
m_nextCoroutine</H3>
<PRE>
int <A HREF="../../../../../src-html/org/apache/xml/dtm/ref/CoroutineManager.html#line.160"><B>m_nextCoroutine</B></A></PRE>
<DL>
<DD>Internal field used to confirm that the coroutine now waking up is
in fact the one we intended to resume. Some such selection mechanism
is needed when more that two coroutines are operating within the same
group.
<P>
<DL>
</DL>
</DL>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="CoroutineManager()"><!-- --></A><H3>
CoroutineManager</H3>
<PRE>
public <A HREF="../../../../../src-html/org/apache/xml/dtm/ref/CoroutineManager.html#line.106"><B>CoroutineManager</B></A>()</PRE>
<DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="co_joinCoroutineSet(int)"><!-- --></A><H3>
co_joinCoroutineSet</H3>
<PRE>
public int <A HREF="../../../../../src-html/org/apache/xml/dtm/ref/CoroutineManager.html#line.184"><B>co_joinCoroutineSet</B></A>(int&nbsp;coroutineID)</PRE>
<DL>
<DD><p>Each coroutine in the set managed by a single
CoroutineManager is identified by a small positive integer. This
brings up the question of how to manage those integers to avoid
reuse... since if two coroutines use the same ID number, resuming
that ID could resume either. I can see arguments for either
allowing applications to select their own numbers (they may want
to declare mnemonics via manefest constants) or generating
numbers on demand. This routine's intended to support both
approaches.</p>
<p>%REVIEW% We could use an object as the identifier. Not sure
it's a net gain, though it would allow the thread to be its own
ID. Ponder.</p>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>coroutineID</CODE> - If >=0, requests that we reserve this number.
If <0, requests that we find, reserve, and return an available ID
number.
<DT><B>Returns:</B><DD>If >=0, the ID number to be used by this coroutine. If <0,
an error occurred -- the ID requested was already in use, or we
couldn't assign one without going over the "unreasonable value" mark</DL>
</DD>
</DL>
<HR>
<A NAME="co_entry_pause(int)"><!-- --></A><H3>
co_entry_pause</H3>
<PRE>
public java.lang.Object <A HREF="../../../../../src-html/org/apache/xml/dtm/ref/CoroutineManager.html#line.226"><B>co_entry_pause</B></A>(int&nbsp;thisCoroutine)
throws java.lang.NoSuchMethodException</PRE>
<DL>
<DD>In the standard coroutine architecture, coroutines are
identified by their method names and are launched and run up to
their first yield by simply resuming them; its's presumed that
this recognizes the not-already-running case and does the right
thing. We seem to need a way to achieve that same threadsafe
run-up... eg, start the coroutine with a wait.
%TBD% whether this makes any sense...
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>thisCoroutine</CODE> - the identifier of this coroutine, so we can
recognize when we are being resumed.
<DT><B>Throws:</B>
<DD><CODE>java.lang.NoSuchMethodException</CODE> - if thisCoroutine isn't
a registered member of this group. %REVIEW% whether this is the
best choice.</DL>
</DD>
</DL>
<HR>
<A NAME="co_resume(java.lang.Object, int, int)"><!-- --></A><H3>
co_resume</H3>
<PRE>
public java.lang.Object <A HREF="../../../../../src-html/org/apache/xml/dtm/ref/CoroutineManager.html#line.261"><B>co_resume</B></A>(java.lang.Object&nbsp;arg_object,
int&nbsp;thisCoroutine,
int&nbsp;toCoroutine)
throws java.lang.NoSuchMethodException</PRE>
<DL>
<DD>Transfer control to another coroutine which has already been started and
is waiting on this CoroutineManager. We won't return from this call
until that routine has relinquished control.
%TBD% What should we do if toCoroutine isn't registered? Exception?
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>arg_object</CODE> - A value to be passed to the other coroutine.<DD><CODE>thisCoroutine</CODE> - Integer identifier for this coroutine. This is the
ID we watch for to see if we're the ones being resumed.<DD><CODE>toCoroutine</CODE> - Integer identifier for the coroutine we wish to
invoke.
<DT><B>Throws:</B>
<DD><CODE>java.lang.NoSuchMethodException</CODE> - if toCoroutine isn't a
registered member of this group. %REVIEW% whether this is the best choice.</DL>
</DD>
</DL>
<HR>
<A NAME="co_exit(int)"><!-- --></A><H3>
co_exit</H3>
<PRE>
public void <A HREF="../../../../../src-html/org/apache/xml/dtm/ref/CoroutineManager.html#line.311"><B>co_exit</B></A>(int&nbsp;thisCoroutine)</PRE>
<DL>
<DD>Terminate this entire set of coroutines. The others will be
deregistered and have exceptions thrown at them. Note that this
is intended as a panic-shutdown operation; under normal
circumstances a coroutine should always end with co_exit_to() in
order to politely inform at least one of its partners that it is
going away.
%TBD% This may need significantly more work.
%TBD% Should this just be co_exit_to(,,CoroutineManager.PANIC)?
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>thisCoroutine</CODE> - Integer identifier for the coroutine requesting exit.</DL>
</DD>
</DL>
<HR>
<A NAME="co_exit_to(java.lang.Object, int, int)"><!-- --></A><H3>
co_exit_to</H3>
<PRE>
public void <A HREF="../../../../../src-html/org/apache/xml/dtm/ref/CoroutineManager.html#line.330"><B>co_exit_to</B></A>(java.lang.Object&nbsp;arg_object,
int&nbsp;thisCoroutine,
int&nbsp;toCoroutine)
throws java.lang.NoSuchMethodException</PRE>
<DL>
<DD>Make the ID available for reuse and terminate this coroutine,
transferring control to the specified coroutine. Note that this
returns immediately rather than waiting for any further coroutine
traffic, so the thread can proceed with other shutdown activities.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>arg_object</CODE> - A value to be passed to the other coroutine.<DD><CODE>thisCoroutine</CODE> - Integer identifier for the coroutine leaving the set.<DD><CODE>toCoroutine</CODE> - Integer identifier for the coroutine we wish to
invoke.
<DT><B>Throws:</B>
<DD><CODE>java.lang.NoSuchMethodException</CODE> - if toCoroutine isn't a
registered member of this group. %REVIEW% whether this is the best choice.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/CoroutineManager.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../org/apache/xml/dtm/ref/ChunkedIntArray.ChunksVector.html" title="class in org.apache.xml.dtm.ref"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../org/apache/xml/dtm/ref/CoroutineParser.html" title="interface in org.apache.xml.dtm.ref"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html?org/apache/xml/dtm/ref/CoroutineManager.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="CoroutineManager.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
</BODY>
</HTML>