.\" @(#)eventHorizons	1.8	12/12/92
.H1 "EventHorizons
.pp
.IE "EventHorizon design"
.IE "universal event horizon"
Like a
.c Star, a
.c Wormhole
may have input and output
.c PortHole s.
The
portholes
of the
wormhole
are called
.i "event horizons" ,
named after the point at which an object that falls into a black hole
disappears from our universe (and presumably reappears in another).
These objects are defined using multiple inheritance: for each such
object, one baseclass is some type of
.c PortHole
and the other baseclass is either
.c ToEventHorizon
or
.c FromEventHorizon ,
each of which are derived from the class
.c EventHorizon .
.pp
Precisely speaking, one
porthole of a wormhole consists of a pair of
event horizons,
one corresponding to the outer domain, and the other corresponding to
the inner domain.  For example, suppose an SDF application has a 
wormhole
.c (SDFWormhole)
which contains a DE subsystem.
Then, an input port of the
wormhole
comprises a
.c SDFtoUniversal
event horizon
and a
.c DEfromUniversal
event horizon.
The former
is connected to the outer domain (to some
.c SDFStar )
and the latter is connected to the inner domain (to some
.c DEStar ).
Similarly, an output port of the wormhole
comprises a
.c DEtoUniversal
event horizon
for the inner connection and a
.c SDFfromUniversal
event horizon
for the outer connection.
.pp
The
.c EventHorizon
class has two derived classes:
.c FromEventHorizon
and
.c ToEventHorizon .
In general, a domain has a pair of derived
event horizons,
one derived from the
.c FromEventHorizon
class and the
.c XXXPortHole
class, where
.c XXX
is the domain
(e.g.
.c SDFfromUniversal,
.c DEfromUniversal ),
and the other from the
.c ToEventHorizon
class and the
.c XXXPortHole
class
(e.g.
.c SDFtoUniversal,
.c DEtoUniversal ).
The
.c receiveData()
method of the
.c ToEventHorizon
class receives data packets from its domain and transfers them to the
counterpart
.c FromEventHorizon
class.
Similarly, the
.c sendData()
method of the
.c FromEventHorizon
class receives data packets from the counterpart 
.c ToEventHorizon
and transfers them to its domain.
Therefore, the data transfer between domains is performed by
calling the 
.c receiveData()
of the
.c ToEventHorizon
first, and calling the 
.c sendData()
of the
.c FromEventHorizon 
next, regardless of whether it happens at an input port or an output port
of the wormhole.
.pp
If data transfer were the sole purpose of the
event horizon,
we would only need one
.c EventHorizon
class.
Unfortunately, there are some domain-specific operations we need to
do in the event horizon.
There are two alternatives to
perform the domain-specific operations.  First, We may optimize each domain
interface by defining a 
.c EventHorizon
class for each pair of domains.  This approach is not attractive
for the highly modularized and easily expandable design of \*(PT.
If we have $N$ domains, we would need to define $N sup 2$ 
.c EventHorizon s.
To make matters worse, if a user wants to add a new domain into \*(PT,
he or she would need to know the details of the existing domains to design the
.c EventHorizon s,
and those designs might need to be modified.
Hence, we have implemented the approach of a ``universal
event horizon'' where each domain
has only a pair of event horizons.
Now, we have only $2N$
.c EventHorizon s
for $N$ domains, and each domain is totally independent of each other.
This mechanism depends on the universality of the universal
event horizon; we consider this approach still experimental.
.pp
While data transfer between two 
domains is the basic function of event horizons,
they also need to manage time stamps for domains that have them.
.IE "time stamp"
Some domains in \*(PT associate a time stamp with each particle
and other domains not.  Since a domain does not know with which domain
it is interacted, the
.c EventHorizon
class of the domain must use a time stamp regardless of the
domain.  Therefore, the time stamp of a
.c ToEventHorizon
is set to be the arrival time of the data packet from its domain, and
the time stamp of a
.c FromEventHorizon
is set equal to that of the paired
.c ToEventHorizon .
.pp
A pair of event horizons for a domain may have other domain-dependent
responsibilities.
One example can be found in
.c DEfromUniversal
class.
This class not only receives particles
but also puts events into the global event queue in the
DE domain (refer to the \fBDE Domain\fR chapter in the \fBAlmagest\fR).
Another example is the 
.c ready()
method in the
.c FromEventHorizon
class.
This method is to check whether the port is ready for the inner domain
to be fired.  For the SDF domain, it returns true only when
it has sufficient data.  Supposing that
the inner domain is SDF and the outer
domain is DE, the inner domain may not be executed until
all input ports of the
.c DEWormhole
have enough data packets.  For that purpose, the 
.c checkReady()
method
of the wormhole checks all
.c FromEventHorizon s
(using the 
.c ready()
method) of the input ports whether they are ready.
For other domains, the 
.c ready()
method can be redefined for
more elaborate synchronization, or ignored if no synchronization is
necessary, as in the DE domain. 
