Next Previous Contents

3. Synchronisation tools

3.1 Mutexes

Simple mutexes

Classical mutex is provided by the rtMutex class. It got essentialy two accesors : P(void) (pick the ``token'') and R(void) (release it).

Recursive mutexes

rtRecursiveMutex (that inherits from rtMutex class) allows a predefined number of ``token'' to be picked at a time. Number is an optional argument to class's constructor (default is 16).

3.2 Shared data

A shared data can be written by one writer, at a time, or readen by many readers. Basic operations are provided by begWrite(void)/endWrite(void) and begRead(void) /endRead(void) methods.

Readers(void) method give the reader's number, and DirectReaders(void) does the same thing without implicitly assuming any other concurent access (this can be useful precautions have been taken by programmer). Anyway, those methods are situated at a very low level, and you probably won't care.

Shared integer

rtSharedInt holds a single shared integer that can be read using Value(void) or DirectValue(void) methods, and sets by set(int _value) or prefixed ++ and -- operators.

3.3 Parameters

A paramater (rtParameter class) has following protected char* members:

Accessors have same name, with an upcased first character.

Integer parameter

rtIntegerParameter is derived from rtParameter and rtSharedInt and can be cloned using the rtIntegerParameter *clone(void) method.

It appears that a intermediate class could introduce a more flexible implementation.

Parameters

rtParameters defines a fixed number of pointers to some parameters. You'll probably need the AddInt(...), GetInt(int _index), and GetInt(char *_name) methods to handle parameters.


Next Previous Contents