sC++
active class S {
public:
m () { ... }
private:
@S () { pseudo-constructor
select {
01 -> m(); external call
instructions ...
||
accept m; accept internal method
instructions ...
||
waituntil (date); time-out
instructions ...
||
default default
instructions ...
}
}
}
slide: Synchronization conditions in sC++
The synchronization conditions for instances of the class
are specified in a select statement
contained in a constructor-like method, which
defines the active body of the object.
Synchronization may take place in either (external) calls to
another active object, internal methods that are
specified as acceptable, or time-out conditions.
When none of the synchronization conditions are met,
a default action may take place.
In addition to the synchronization conditions mentioned,
a when guard-statement may occur in any of the clauses
of select,
to specify conditions on the state of the object or
real-time constraints.
The sC++ language is implemented as an extension to the GNU C++ compiler.
The sC++ runtime environment offers the possibility
to validate a program by executing random walks,
which is a powerful way to check the various synchronization conditions.
The model of active objects supported by sC++
has also been realized as a Java library, see [Petitpierre99].
There is currently, however, no preprocessor or compiler
for Java supporting synchronous active objects.
As argumented in [Petitpierre98], one of the advantages of
synchronous active objects is that they allow us
to do away with event-loops and callbacks.
Another, perhaps more important, advantage is that the model
bears a close relationship with formal models of concurrency
as embodied by CCS and CSP,
which opens opportunities for the verification and validation
of concurrent object-oriented programs.
In conclusion, in my opinion, the active object model discussed
deserves to become a standard for both C++ and Java,
not because it unifies the concurrency model for these languages,
which is for example also done by JThreads++ described in [JThreads],
but because it offers a high level of abstraction suitable
for concurrent object-oriented software engineering.