Previous: The ::this Pointer Up: Processor Objects Next: Examples
Pitfalls
Take care to remember these things when using processor objects:
- Multiple threads of control can be executing on one processor
object at any one time, since anyone with a global pointer to a
processor object can perform an RPC. Use atomic and sync to
prevent dangerous sharing.
- The destructor for a processor object is just another member
function of that object. It can be running concurrently with other
threads on the processor object, and will not wait for those other threads
to finish before deallocating the processor object. In CC++ it is bad
style to finish a computation when all processor objects have not been
deallocated. The system will try to deallocate those processor objects
left by the user. The system is not always able to do this, and in CC++
the consequences of an undeallocated processor object are significant: a
process left running, wasting processor time and resources. That process
may even exist on another machine. Ending a computation with exit()
from any processor object guarantees that all processor objects are
deleted, while ending it with abort() will not. Killing a single
process in the computation, for instance using the UNIX kill
command, will not terminate the entire computation.
In addition, the current implementation has the following pitfalls:
- The syntax delete [] to delete an array of pointers cannot be
used with an array of pointers to processor objects.
- CC++ defines a function, called the entry function, for each
type to handle RPCs to objects of that type. This function is
automatically generated by the compiler. When compiling many modules
into one executable, the same type can be declared many times. If the
entry function is defined in each module, a link-time error will
result. Because of this, CC++ defines the entry function for a type
at the point of the first non-inline non-constructor member function
of that type. If there are no non-inline non-constructor members of a
type, you can force entry functions to be defined at the point of type
declaration by using the compiler option +ee1.