csp::DeadlockError Class Reference

Inheritance diagram for csp::DeadlockError:

csp::CPPCSPError List of all members.

Detailed Description

Thrown when deadlock occurs in a C++CSP2 program; it is a fatal, unrecoverable error.

If you do catch the error, your only course of action is to try and terminate the program as tidily as possible. Do not try to continue using C++CSP2, by communicating over channels or starting new processes, as the behaviour of this will be undefined (this error may be thrown again, for example).

Deadlock occurs when all C++CSP2 processes are blocked with the C++CSP2 system (waiting for channel communication, barriers or buckets). It will only occur if your program has a latent error in it that allows deadlock to arise. If you receive this error, examine the structure of your process network to see how this could have occurred.

This error is always thrown inside the original process that called Start_CPPCSP(). This is for your convenience, so that when you want to track down the cause of this error, you do not have to catch DeadlockError in all your processes, just in case that process "encounter" the deadlock (i.e. is the last process to block).

To aid in this post-mortem examination, you may want to use the recentBlocks variable (and/or the translate() method).

C++CSP2 will only throw a DeadlockError when all processes are blocked on C++CSP2 synchronisation. For example, if you have two processes in your system, one waiting for a channel communication and one blocked waiting for user input, that is not deadlock -- because as far as C++CSP2 is concerned, the process waiting for user input is not blocked.


Public Member Functions

std::list< std::string > translate (const std::map< ThreadCSProcess const *, std::string > &names)
 Translates the recentBlocks list using a dictionary of process names.

Public Attributes

const std::list< internal::Process
const * > 
recentBlocks
 A list of the most recent blocks (waits) by processes in your C++CSP2 system.


Member Function Documentation

std::list< std::string > csp::DeadlockError::translate ( const std::map< ThreadCSProcess const *, std::string > &  names  )  [inline]

Translates the recentBlocks list using a dictionary of process names.

You pass to this method a std::map that maps process pointers to names (std::string objects, which can contain whatever text you wish to use to label the process). The method then tries to look-up the name for each recent block. If the pointer is in the map, the corresponding name is used. If the pointer is not in the map, it is simply converted into text (e.g. 0x12345678).

A list is returned that is the same size as recentBlocks, with each entry translated as described above.

Parameters:
names The map between process pointers and names.
Returns:
The list of names/pointers of processes.


Member Data Documentation

const std::list< internal::Process const *> csp::DeadlockError::recentBlocks

A list of the most recent blocks (waits) by processes in your C++CSP2 system.

Processes are identified by pointer/address. You may encounter duplicates in this list for two reasons:

The pointers may not still be valid, so do not try to dereference them -- it is quite possible that they point to a since-deleted process.

These pointers are to an internal class -- you will need to use the translate() method to make sense of them.


Generated on Mon Aug 20 12:24:29 2007 for C++CSP2 by  doxygen 1.4.7