### ISynchronized

  ISynchronized is a template class that is designed to make atomic get, set, and swap operations typesafe and convenient. Most operating systems (or CPUs actually if you want to be specific) offer a mechanism by which a pointer or integral value can be read, written, or exchanged in such a way that they are guaranteed not to be interrupted by another thread, even on a multiple CPU machine.

  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.

### ISynchronized - Member Functions and Data by Group

### Data Access Methods

Provides access to the data in the synchronized object.

get

      public:
      AType get() const

  Atomically retrieves the current value of the fAtom data member. Keep in mind that, in a multi-threaded environment, this returned value is only advisory. It could be changed by another thread at any time. The fact that ISynchronized prevents multiple access to a data field does not mean you do not have to control your threads' access to the data.

Return
  The current value of the object pointed to by the fAtom member.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

set

      public:
      void set(AType newValue)

  Sets the value of the fAtom member atomically. This is an unconditional set of the member and the previous value is just overwritten.

  newValue
    is the new value to set. It will replace the current value.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

setConditional

      public:
      int setConditional(AType test, AType newValue)

  Conditionally sets the fAtom member atomically, if the passed test value equals the current value of the fAtom member. Otherwise, nothing is returned.

  test
    is the value to test against the current value, to see if the swap should occur.
  newValue
    is the new value to set if the test value matches the current value

Return
  false if the new value was set, else true.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Operators

Provides access to the data object being synchronized.

operator AType

      public:
      operator AType() const

  An implicit conversion operator to extract the value of the fAtom member when the ISynchronized object is used. This allows you to just pass the ISynchronized object when a value of the template specialization class is required. This operator does the same thing as get(), so use get() if you don't feel comfortable with this type of magical implicit extraction.

Return
  The current value of the object pointed to by fAtom

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Public Data Members

Public data members.

fAtom

      public:
      AType fAtom

  fAtom is the data member that is operated upon by the atomic operations. It is public so that it gets normal C style static initialization.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### ISynchronized - Inherited Member Functions and Data

#### Inherited Public Functions

  - None

#### Inherited Public Data

  - None

#### Inherited Protected Functions

  - None

#### Inherited Protected Data

  - None