Quantitative Analysis
Parallel Processing
Numerical Analysis
C++ Multithreading
Python for Excel
Python Utilities
Services
Author

I. Installation.
II. Threading primitives.
1. Encapsulation of primitives.
2. Preventing starvation.
3. Preventing race condition.
A. Guard primitives.
a. ReaderGuard.
b. WriterGuard.
c. UpgradeGuard.
d. TryGuard.
4. Barriers.
III. NonBlockingQueue.
IV. ThreadPool.
V. ThreadMaster.
VI. OTS Scheduler.
VII. Bibliography
Downloads. Index. Contents.

ReaderGuard.


he ReaderGuard is used to remove volatileness and simultaneously gain access to the const-part of the shared object's interface. It performs shared (reader) locking of the mutex exposed by the shared object.

The following is the public interface of the ReaderGuard.

template <class X,class Mutex>

class ReaderGuard

{

public:

explicit ReaderGuard( volatile const X& x );

explicit ReaderGuard( volatile const X* x );

ReaderGuard( volatile const X& x, volatile const Mutex& mutex );

ReaderGuard( volatile const X* x, volatile const Mutex& mutex );

~ReaderGuard();

Mutex& mutex() const;

const X* operator->() const;

const X& operator*() const;

const X* ptr() const;

};

All constructors throw boost::thread_resource_error. All other functions do not throw.

See the section ( Preventing race condition section ) for an example.





Downloads. Index. Contents.


















Copyright 2007