Home Libraries Author Links

StmThreadSpecific<ItemType> Example
[Abstract Data Type Family StmThreadSpecific<ItemType>]

Collaboration diagram for StmThreadSpecific<ItemType> Example:

Detailed Description

Example of an abstract thread-specific type with the abstract item type SampleStateType.

SampleThreadSpecific.

If the abstract thread-specific type StmThreadSpecificSampleStateType is defined by

      StmThreadSpecificItemDefine (SampleStateType)
the following types and functions are generated.


Files

file  StmThreadSpecificSampleStateTypeDoc.h
 Documentation of the abstract thread-specific type StmThreadSpecificSampleStateType.
file  SampleStateTypeAdtDoc.h
 Documentation of the abstract structure data type type SampleStateType.

StmThreadSpecificSampleStateType Representation

An object of abstract data type StmThreadSpecificSampleStateType is represented as a StmThreadSpecific object.

Valid objects of type StmThreadSpecificSampleStateType can be achieved only as return values of stmThreadSpecificSampleStateTypeCreate(). Moreover, variables of type StmThreadSpecificSampleStateType may have the value NULL meaning invalid or undefined.

typedef StmThreadSpecific StmThreadSpecificSampleStateType
 Object type.
typedef ConstStmThreadSpecific ConstStmThreadSpecificSampleStateType
 Constant object type.

SampleStateType Representation

An object of abstract data type SampleStateType is represented as a pointer to its implementation.

typedef struct SampleStateTypeImpl_ SampleStateTypeImpl_
 Type name of implementation structure.
typedef SampleStateTypeImpl_SampleStateType
 Pointer to implementation.
typedef const
SampleStateTypeImpl_
ConstSampleStateType
 Pointer to constant implementation.

StmThreadSpecificSampleStateType Creation and Destruction

static
StmThreadSpecificSampleStateType 
stmThreadSpecificSampleStateTypeCreate (void)
 Creation of a new StmThreadSpecificSampleStateType object.
static int stmThreadSpecificSampleStateTypeDestroy (StmThreadSpecificSampleStateType tsi)
 Destruction of the StmThreadSpecificSampleStateType object tsi.

StmThreadSpecificSampleStateType Method Functions

static SampleStateType stmThreadSpecificSampleStateTypeGet (StmThreadSpecificSampleStateType tsi)
 Return the SampleStateType object of tsi associated with the calling thread.
static int stmThreadSpecificSampleStateTypeSet (StmThreadSpecificSampleStateType tsi, ConstSampleStateType item)
 Set the SampleStateType object of tsi associated with the calling thread.

Functions

void SampleStateTypeDestroy (SampleStateType item)
 SampleStateType destuction function required by the StmThreadSpecificItemDefine macro.


Typedef Documentation

typedef StmThreadSpecific StmThreadSpecificSampleStateType

Object type.

Definition at line 69 of file StmThreadSpecificSampleStateTypeDoc.h.

typedef ConstStmThreadSpecific ConstStmThreadSpecificSampleStateType

Constant object type.

Definition at line 74 of file StmThreadSpecificSampleStateTypeDoc.h.

typedef struct SampleStateTypeImpl_ SampleStateTypeImpl_

Type name of implementation structure.

Definition at line 60 of file SampleStateTypeAdtDoc.h.

typedef SampleStateTypeImpl_* SampleStateType

Pointer to implementation.

Definition at line 63 of file SampleStateTypeAdtDoc.h.

typedef const SampleStateTypeImpl_* ConstSampleStateType

Pointer to constant implementation.

Definition at line 66 of file SampleStateTypeAdtDoc.h.


Function Documentation

void SampleStateTypeDestroy ( SampleStateType  item  ) 

SampleStateType destuction function required by the StmThreadSpecificItemDefine macro.

static StmThreadSpecificSampleStateType stmThreadSpecificSampleStateTypeCreate ( void   )  [static]

Creation of a new StmThreadSpecificSampleStateType object.

Effects:
The function creates a StmThreadSpecificSampleStateType object visible to all threads in the process. The StmThreadSpecificSampleStateType objects provided by stmThreadSpecificSampleStateTypeCreate() are used to locate thread-specific SampleStateType objects. Although the same StmThreadSpecificSampleStateType object may be used by different threads, the SampleStateType objects bound to the StmThreadSpecificSampleStateType object by stmThreadSpecificSampleStateTypeSet() are maintained on a per-thread basis and persist for the life of the calling thread.
Upon StmThreadSpecificSampleStateType object creation, the value NULL representing an undefined SampleStateType object is associated with the new object in all active threads. Upon thread creation, the value NULL is associated with all defined StmThreadSpecificSampleStateType objects in the new thread.
At thread exit, if the thread has a non-NULL SampleStateType object associated with a StmThreadSpecificSampleStateType object, the SampleStateType object is set to NULL, and then the destructor function SampleStateTypeDestroy() is called with the previously associated SampleStateType object as its sole argument.
Returns:
NULL on error. Then the variable errno contains the error's cause.

The StmThreadSpecificSampleStateType object created on success.

See also:
stmThreadSpecificSampleStateTypeDestroy(), stmThreadSpecificSampleStateTypeGet(), stmThreadSpecificSampleStateTypeSet().

static int stmThreadSpecificSampleStateTypeDestroy ( StmThreadSpecificSampleStateType  tsi  )  [static]

Destruction of the StmThreadSpecificSampleStateType object tsi.

Parameters:
[in] tsi The StmThreadSpecificSampleStateType object to be destroyed.
Effects:
The function destroys the StmThreadSpecificSampleStateType object tsi. It is no error to call the function for an invalid StmThreadSpecificSampleStateType object with value NULL in which case the function does nothing.
The thread-specific SampleStateType objects associated with tsi need not be NULL at the time stmThreadSpecificSampleStateTypeDestroy() is called. It is the responsibility of the application to perform any cleanup actions for associated thread-specific SampleStateType objects in any threads. This cleanup can be done either before or after stmThreadSpecificSampleStateTypeDestroy() is called. Any attempt to use tsi following the call to stmThreadSpecificSampleStateTypeDestroy() results in undefined behavior.
The destructor function SampleStateTypeDestroy() is no longer called upon thread exit.
Returns:
-1 on error. Then the variable errno contains the error's cause and the StmThreadSpecificSampleStateType object is not destroyed.

0 on success.

See also:
stmThreadSpecificSampleStateTypeCreate(), stmThreadSpecificSampleStateTypeGet(), stmThreadSpecificSampleStateTypeSet().

static SampleStateType stmThreadSpecificSampleStateTypeGet ( StmThreadSpecificSampleStateType  tsi  )  [static]

Return the SampleStateType object of tsi associated with the calling thread.

Parameters:
[in] tsi The StmThreadSpecificSampleStateType object.
Returns:
NULL, if no vaild thread-specific SampleStateType object is associated with tsi for the calling thread.

The SampleStateType object currently bound to tsi on behalf of the calling thread.

Note:
For performance reasons no error return is provided.
See also:
stmThreadSpecificSampleStateTypeCreate(), stmThreadSpecificSampleStateTypeDestroy(), stmThreadSpecificSampleStateTypeSet().

static int stmThreadSpecificSampleStateTypeSet ( StmThreadSpecificSampleStateType  tsi,
ConstSampleStateType  item 
) [static]

Set the SampleStateType object of tsi associated with the calling thread.

Parameters:
[in] tsi The StmThreadSpecificSampleStateType object.
[in] item SampleStateType object to be associated.
Effects:
The function associates for the calling thread the thread-specific SampleStateType object item with the StmThreadSpecificSampleStateType object tsi.
Note:
Different threads may bind different SampleStateType objects to the same StmThreadSpecificSampleStateType object.
Returns:
-1 on error. Then the variable errno contains the error's cause and the void pointer is not set.

0 on success.

See also:
stmThreadSpecificSampleStateTypeCreate(), stmThreadSpecificSampleStateTypeDestroy(), stmThreadSpecificSampleStateTypeGet().


© Copyright Tom Michaelis 2002-2007

Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).