DM1 Threads Library 1.0.5 reviewDownload
DM1 Thread Library is part of the DM1 project
DM1 Thread Library is part of the DM1 project. This library was born out of my need to have a portable C++ Thread library that would be simple to use, and would provide all the necessary Threads functionality I required for the DM1 project.
Initially, this library was in C, but when I decided to re-write DM1 in C++, I ported the library to C++. During the port, I enhanced the functionality of the Threads library.
The DM1 Threads library aims to be small. It does not try to provide a comprehensive set of functionality, but only what is absolutely essential for a project like DM1. I had the simplicity of the Java Threads package in mind when creating this library.
The constructs provided by the DM1 Thread library are:
Thread objects that represent Operating System threads.
A Mutex is provided as a mechanism for Mutual Exclusion . Mutexes are used to ensure that a piece of code is executed by only one thread at any point in time.
Events are provided as low-level mechanisms for thread synchronisation. Events can be waited for, and signalled to.
A higher level object, that combines the functionality of an Event and a Mutex, is provided. This is the Monitor object. A Monitor can be locked exclusively, just like a Mutex, but it can also be made the object of a Wait operation. The signalling mechanism supports notification of one or more waiting threads.
To enable more efficient locking when both shared and exclusive access to data is required, Latches are provided.
Apart from the Thread synchronisation primitives described above, the library also provides a ThreadPool for the situation when it is inefficient to create a thread exclusively for a particular task, and it is desirable to share a pool of threads for executing multiple tasks.
The DM1 Threads library was designed with the following principles in mind:
1. Implement the bare minimum that is required. This Threads library does not aim to be a comprehensive threads package.
2. Avoid complex algorithms. If a particular construct is hard to implement correctly on all platforms, avoid it.
3. Document the library.
4. Avoid low level code, such as assembler code to implement Spin locks. Rely on the libraries provided by the Operating System.
5. Avoid holding Mutexes beyond function calls. A DM1 Thread library function will not hold any Mutex locks when it returns.
6. Avoid using clever C++ techniques wherever possible. (Unfortunately, some cleverness is required to implement the Thread class correctly).
7. Avoid dependency on external libraries. The DM1 library only requires the standard C library, apart from native Threads functionality.
8. Always report an error as soon as it is discovered.
9. Insert debug messages that can be switched on at run-time.
10. Do not throw exceptions from destructors because these might be executing as a result of an uncaught exception.
11. Never let an error go unreported.
DM1 Threads Library 1.0.5 keywords