In general, you will want to use higher level synchronization mechanism, such as the IResource or ICondition family of classes to synchronize multiple threaded code; however, you sometimes will require a way to insure thread safety for some sort of primitive type operation. ISynchronized provides that support.
The operating system or CPU support provided for these operations is inherently typeless, and a little complex sometimes when the values to be exchanged, gotten, or set are themselves pointers. ISynchronized, being a template class, can easily handle all of the typelessness of you. It does any casting of incoming and returned values so that you don't have to worry about those issues.
Each ISynchronized object contains a data member, fAtom, which is an instance of the template specialization type. This is the member that is operated on by all of the atomic operation methods. This data member is guaranteed to have a value of 0 when the object is constructed. The template specialization type must be a 32-bit aligned primitive data type.
Data Access MethodsProvides access to the data in the synchronized object.
![]() |
public:
AType get() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
void set(AType newValue)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
int setConditional(AType test, AType newValue)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
OperatorsProvides access to the data object being synchronized.
![]() |
public:
operator AType() const
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Public Data MembersPublic data members.
![]() |
public:
AType fAtom
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |