library of assembled shared sources

http://lass.cocamware.com

Threading

Threading functions. More...


Data Structures

class  lass::util::RWLock
 Lean and mean synchronisation object, without OS support. More...
class  lass::util::Mutex
 Mutex. More...
class  lass::util::CriticalSection
 CriticalSection. More...
class  lass::util::Condition
 Condition. More...
class  lass::util::Thread
 A base class for threads. More...
class  lass::util::ThreadLocalStorage
 A primitive to provide Thread Local Storage functionality. More...
class  lass::util::ThreadLocalVariable< T >
 A primitive to provide Thread Local Storage functionality for a first-citizen class. More...
class  lass::util::Semaphore
 Lean and mean synchronisation object, without OS support. More...
class  lass::util::LockerBase
 Common base class for lockers. More...
class  lass::util::Locker< LockType >
class  lass::util::DefaultConsumer< TaskType >
 Default consumer calls operator() of task. More...
class  lass::util::Spinning
 implementation of ThreadPool's IdlePolicy More...
class  lass::util::Signaled
 implementation of ThreadPool's IdlePolicy More...
class  lass::util::SelfParticipating< TaskType, ConsumerType, IdlePolicy >
 implementation of ThreadPool's ParticipationPolicy More...
class  lass::util::NotParticipating< TaskType, ConsumerType, IdlePolicy >
 implementation of ThreadPool's ParticipationPolicy More...
class  ThreadPool
 Production-Consumer concurrency pattern. More...

Defines

#define LASS_LOCK(iLock)
 Locks a iLock and starts a scope block in which it remains locked.

Typedefs

typedef Locker< Mutex > lass::util::MutexLocker
 typedef of Locker for Mutex
typedef Locker< CriticalSection > lass::util::CriticalSectionLocker
 typedef of Locker for CriticalSection
typedef Locker< Semaphore > lass::util::SemaphoreLocker
 typedef of Locker for Semaphore

Enumerations

enum  lass::util::LockResult { lass::util::lockSuccess, lass::util::lockBusy }
 Return code for lock functions. More...
enum  lass::util::WaitResult { lass::util::waitSuccess, lass::util::waitTimeout }
 Return code for wait functions. More...
enum  lass::util::ThreadKind { lass::util::threadDetached, lass::util::threadJoinable }
 ThreadKind. More...

Functions

template<typename T >
Locker< T > lass::util::Locker::makeLocker (T &iLock)

Variables

unsigned lass::util::numberOfProcessors = impl::numberOfProcessors()


Detailed Description

Threading functions.

The Mutex and Thread classes for WIN32 are almost literal copy and pastes of the functions of wxWindows2.4.2. The implementation has changed a little bit to use more of the LASS utility functions. The most noticible difference is in the thread class where the Delete is not implemented, due to too large dependencies. The Critical Section on WIN32 is an own implementation, just like all the UNIX Posix threading stuff.

A little word on synchronization: in windows there are quite a few synchronisation primitives and synchronized objects. Only the most common are implemented and wrapped in the LASS environment: Mutex : system-wide synchronisation object between processes/threads. Mutexes set in one process can be unlocked in another one. That is the theory. In practice with the LASS wrapping, there is no possibility to reference these mutexes in other processes, named mutexes are not supported. Mutex are rather heavyweight structures. Cannot be used for intrathread synchronisation AFAIK [TDM] CriticalSection : process-wide synchronisation object between threads. Lightweight construction. Cannot be used for intra-thread synchronisation. Condition: this corresponds with MS Windows Events, can be used for interprocess/ interthread and intrathread synchronisation. Not implemented in UNIX build.


Define Documentation

#define LASS_LOCK ( iLock   ) 

Value:

if (const ::lass::util::LockerBase& LASS_UNUSED(lassUtilImplLocker) =\
        ::lass::util::makeLocker(iLock))\
    {\
        LASS_ASSERT_UNREACHABLE;\
    }\
    else
Locks a iLock and starts a scope block in which it remains locked.

Author:
[Bramz]
This macro starts a scope block through a if/else construct where the lock will be locked on entering the scope, and will be unlocked on leaving the scope. You can use this scope in two ways: by using the braces:

  LASS_LOCK(lock)
  {
      // locked
      doSomethingWhileLocked();
  }
  // unlocked

Because the macro uses an if/else construct, you can ommit the braces if you only need one statement in the locked scope:

  LASS_LOCK(lock) doSomethingWhileLocked();

requirements for iLock:
iLock can be of any type that implements two methods lock() and unlock(), that have to do the obvious thing. Two excellent types to be used are lass::util::Mutex and lass::util::CriticalSection.
references:
Concurrent Acces Control & C++, C/C++ Users Journal, January 2004
Note:
Guess what, for some reason bill gates might know, LASS_UNIQUENAME(lassUtilImplGenericLocker) causes troubles in the win32_vc7_d build. huray! Does the concatenation fails? It seems not, since in the preprocessor files everything seems fine. And yet, it breaks. Hence, we had to give up on it, there's only lassUtilImplGenericLocker now. I don't think that will cause any problems, since it's inside an if/else scope block. But if you get name conflicts on LASS_LOCK, this might be the reason ...

Definition at line 512 of file thread.h.

Referenced by lass::python::PyObjectCounter::decrement(), lass::io::BinaryOSocket::doWrite(), lass::io::BinaryOSocket::flusher(), lass::python::fromNakedToSharedPtrCast(), lass::python::fromSharedPtrToNakedCast(), lass::python::PyObjectCounter::increment(), lass::util::Singleton< T, destructPriority >::instance(), lass::spat::experimental::ResetableThreadLocalVariable< TEdge * >::registerImpl(), lass::spat::experimental::ResetableThreadLocalVariable< TEdge * >::reset(), lass::util::impl::CrashDumpImpl::unhandledExceptionFilter(), and lass::spat::experimental::ResetableThreadLocalVariable< TEdge * >::unregisterImpl().


Typedef Documentation

typedef Locker<Mutex> lass::util::MutexLocker

typedef of Locker for Mutex

See also:
Mutex

Locker

Definition at line 452 of file thread.h.

typedef Locker<CriticalSection> lass::util::CriticalSectionLocker

typedef of Locker for CriticalSection

See also:
CriticalSection

Locker

Definition at line 459 of file thread.h.

typedef Locker<Semaphore> lass::util::SemaphoreLocker

typedef of Locker for Semaphore

See also:
Semaphore

Locker

Definition at line 466 of file thread.h.


Enumeration Type Documentation

Return code for lock functions.

See also:
Mutex,CriticalSection
Enumerator:
lockSuccess  Mutex/CriticalSection is succesfully locked by this thread.
lockBusy  Mutex/CriticalSection is locked by another thread.

Definition at line 88 of file thread.h.

Return code for wait functions.

See also:
Condition
Enumerator:
waitSuccess  Wait is successfully terminated.
waitTimeout  Wait failed because of a timeout.

Definition at line 98 of file thread.h.

ThreadKind.

See also:
Thread
Enumerator:
threadDetached  detached thread
threadJoinable  joinable thread, can be waited for

Definition at line 108 of file thread.h.


Function Documentation

template<typename T >
Locker< T > makeLocker ( T &  iLock  )  [related, inherited]

Definition at line 442 of file thread.h.


Variable Documentation

LASS_DLL unsigned lass::util::numberOfProcessors = impl::numberOfProcessors()


Generated on Mon Nov 10 14:22:07 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo