Quantitative Analysis.
Trading Platform.
Python for Excel.
Author.
I.Installation.
II.OTS Scheduler.
1.Threading primitives.
A.Encapsulation of primitives.
B.Preventing starvation.
C.Preventing race condition.
a.Guard primitives.
i.ReaderGuard.
ii.WriterGuard.
iii.UpgradeGuard.
iv.TryGuard.
D.Barriers.
2.NonBlockingQueue.
3.ThreadPool.
4.ThreadMaster.
5.Scheduler implementation.
III.OTS Python Object Browser.
Bibliography.
Forum Index Contents Downloads

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.





Forum Index Contents Download


















Copyright 2009.