Documentation for The Kent C++ CSP Library
1.3.2
This is a CSP system for C++. It was originally developed at the University of Kent as a final year BSc project and is now developed and maintained with their permission.
CSP is a concurrency model originally developed by C.A.R. Hoare. It involves many processes which can run sequentially or in parallel, that can only interact with each other via communication channels.
See also:
This documentation is a reference manual for the users of this library. It is designed to help the user easily browse through the structure of the library and determine how to use the classes and functions contained in it.
It is not intended to be a full introduction to C++CSP or CSP. Hopefully if it is worked on enough it will become that, but the primary aim is to properly document the API.
Also of use is the paper written as an introduction to the library, and also (just in case it helps) the presentation that accompanied it:
There is also the second paper on C++CSP, which describes the addition of the networked component, its design and rationale:
This documentation was auto-generated from the original code of the library using Doxygen, an excellent javadoc-like program for C++. The latest version is available from www.doxygen.org. If you have doxygen installed, typing "make docs" in the C++CSP source directory should generate this documentation.
The author of the library can be reached here.
A debt of gratitude is owed to Peter Welch for his support of the library's development. All the attendees of the CPA conferences have been receptive and helpful to me in my endeavours. Thanks also to Alan Grover for his helpful suggestions and reports on using C++CSP. This library is dependent on the Boost C++ libraries, and the author extends his thanks to the developers of boost for releasing a useful and clever library to the world, which I continue to use in other projects.
CSP is actually a process algebra -- a mathematical notation for describing (potentially) concurrent programs and reasoning about them. A lot of work is done on CSP in this area, but this is not actually where my interest in CSP is focused. To me, CSP is an essential computing paradigm, as useful (if not more so) as object-orientation.
CSP can (there are many ways to describe it) be viewed as part way between imperative (such as in C) and event-driven (such as in Visual Basic) programming. A ubiquitous task in programming on desktop machines is that of handling GUI events (keyboard input, button presses, refresh notifications etc.)
To accomplish this in imperative languages, the usual way of doing things is:
Loop until quit:
-
Call a WaitForEvents function (will block until events occur)
-
Handle the events
What if we wanted to be doing a background task while waiting for events though? Generally this paradigm is used:
Loop until quit:
-
Call a PollEvents function (will return almost immediately)
-
Handle the events if there were any
-
Perform background task
The problem with this solution is that if the background task takes a long time and cannot properly be subdivided (for example rendering a complex 3D scene that takes a second or two) then the user will find that their input (e.g. mouse clicks) are not acted upon for some time. The solution would be to utilise multi-threading, but everyone (from amateurs to experts alike) seems to agree that multi-threading is complex and dangerous, and is a last resort. Also, many GUIs have problems with multi-threading for these reasons.
Event-driven programming just has many handler functions for different events that are called when the events occur, with no (visible) central thread of control. Performing background tasks alongside causes problems; since the task has to be performed in an event handler (which will therefore not return until the task is done), the same problem would occur with lagging input.
The CSP model would solve this problem by having some process(es) waiting for events and handling them as follows:
Process HandleButtonPress:
-
Loop until done:
-
Wait for input on a NotifyButtonPress channel
-
Perform desired action because of button press
Then the CSP model would also have a process to perform the background task:
Process DoBackgroundTask:
The CSP system would then run these in parallel with each other (i.e. concurrently) and the problem would be solved.
Generated on Wed May 18 22:51:48 2005 for The Kent C++CSP Library by
1.4.2