VR-Link API Documentation for DIS
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
DtScopedSequenceLock Class Reference

A scoped sequence lock. More...

+ Inheritance diagram for DtScopedSequenceLock:
+ Collaboration diagram for DtScopedSequenceLock:

List of all members.

Public Types

typedef void(* LockFunction )(void *)
 Define Lock function.

Public Member Functions

 DtScopedSequenceLock (const DtScopedSequenceLock &orig)
 Public copy constructor, is called on return from the implementation/ This method creates the lock.
virtual ~DtScopedSequenceLock ()
 Destructor, unlocks the object.

Protected Member Functions

 DtScopedSequenceLock (void *object, LockFunction lockCB, LockFunction unlockCB)
 Protected constructor is called by private implementation of lock.

Protected Attributes

LockFunction myLockCallback
 The acquire lock callback.
LockFunction myUnlockCallback
 The release lock callback.
void * myObject
 The object to pass to the callbacks.

Detailed Description

A scoped sequence lock.

A scoped sequence lock, maintains a lock on an DtThreadSafe object until it goes out of scope. DtScopedSequenceLock is return by value from a DtThreadSafe object and should not be copied or maintained. A sequence lock is required when multiple operations are performed that need to be atomic.

A DtScopedSequenceLock requires several additional locks and thus is more expensive than normal ThreadSafe calls. However each additional call in a sequence may be slightly cheaper due to it already having the lock. It is faster to copy the DtThreadSafe to a local object and do the operations then reassign it, however this may not always be possible. The exception to this is if copying is overly expensive.

It is not possible to create a DtScopedSequenceLock as the implementation of its lock and unlock callbacks are defined by the DtThreadSafe object

 DtThreadSafe<DtString> stringTS("Hello World");
 {   
    DtScopedSequenceLock sequenceLock = stringTS.sequenceLock();
    ... all calls to stringTS in this scope will now be single threaded.
 }

Member Typedef Documentation

typedef void(* DtScopedSequenceLock::LockFunction)(void *)

Define Lock function.


Constructor & Destructor Documentation

Public copy constructor, is called on return from the implementation/ This method creates the lock.

Destructor, unlocks the object.

DtScopedSequenceLock::DtScopedSequenceLock ( void *  object,
LockFunction  lockCB,
LockFunction  unlockCB 
) [protected]

Protected constructor is called by private implementation of lock.


Member Data Documentation

The acquire lock callback.

void* DtScopedSequenceLock::myObject [protected]

The object to pass to the callbacks.

The release lock callback.


The documentation for this class was generated from the following file:

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)