
CSyncCollection
v1.08 A templatized collection with thread synchronization
Welcome to CSyncCollection, an MFC class
which implements a templatized collection which implements thread
synchronisation with timeouts for both adding and removing. In other words when
you "Add", you can specify a timeout to wait for if the collection is
full and if when you "Remove" data from the collection you can
specify a timeout to wait for if the collection is empty. Making the class
templatized means that you can store any type of data you want on in it. In
addition templates are used to define various collection types. The code comes
with predefined templates for both a stack and queue collection.
The enclosed zip file contains
source for the class and a test program which implements a simulation of the
classic consumer / producer thread synchronisation example.
Copyright
- You are allowed to include the source code in
any product (commercial, shareware, freeware or otherwise) when your product
is released in binary form.
- You are allowed to modify the source code in
any way you want except you cannot modify the copyright details at the top
of each module.
- If you want to distribute source code with
your application, then you are only allowed to distribute versions released
by the author. This is to maintain a single distribution point for the
source code.
Updates
v1.0 (26 January 2002)
V1.01 (6 April 2002)
- Sorted out some linker
problems for the Win32 Debug and Win32 Release build configurations.
V1.02 (7 April 2002)
- Added a CEvent to the main class to allow synchronisation with data becoming available in the collection without actually having to remove it.
V1.03 (23 November 2003)
- Fixed a potential thread race condition in
CSyncCollection::Remove
V1.04 (26 November 2004)
- Fixed a number of compiler warnings when the code is
compiled on VC .Net 2003
V1.05 (30 May 2005)
- Now uses a auto-reset event to signal that items are available instead of a manual reset. Also the event is now created using the Win32 API rather than using the MFC CEvent wrapper class.
- Updated the text in some of the TRACE statements.
V1.06 (10 April 2006)
- The CSyncCollection class now provides Lock and unlock methods to allow
external synchronisation.
- CSyncCollection::GetSize, Add, Remove & Close now includes a parameter
which decides if internal locking should be done. Again this allows more
fine tuned external synchronisation of the class
- Addition of a CCSYNCCOLLECTION_EXT_CLASS macro to make it more easier to
use the class in an extension dll.
- Updated the documentation to use the same style as the web site.
- Did a spell check of the documentation.
V1.06 (10 April 2006)
- The CSyncCollection class now provides Lock and unlock methods to allow
external synchronisation.
V1.07 (2 May 2006)
- Removed the need to have the collection class methods virtual. After all
you can think of C++ templates as compile time polymorphism while virtual
functions give you runtime polymorphism.
V1.08 (7 July 2008)
- Updated copyright details.
- Removed the CSYNCCOLLECTION_EXT_CLASS proprocessor value as it is not
required since the class is template based.
- The code has now been updated to support VC 2005 or later only.
- Updated the sample app to clean compile on VC 2008
- Code now compiles cleanly using Code Analysis (/analyze)
- Code now uses newer C++ style casts instead of C style casts.