ISharedCondition
- Shared conditions are named versions of the basic condition class. See the parent class for a
full description of what conditions are and how they are used.
ISharedCondition - Member Functions and Data by Group
Constructors & Destructor
Construct and destruct shared condition objects.
- ~ISharedCondition
public:
virtual ~ISharedCondition()
- The destructor destroys the platform specific mechanisms which are used to implement the condition;
however, since these mechanisms are also named and shared, they are not actually closed until all users
of them have destroyed their copies.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
- ISharedCondition
- Constructs a shared condition object. A shared condition may be used by multiple processes, as long
as those processes know the name of condition.
If the condition already exists, its opened; else, it is created if the name if legal.
Overload 1
- Constructs a shared condition object, with a uniquely generated name.
public:
ISharedCondition()
- The default constructor generates a unique name for the condition. In order to be used by other processes, this name would have to be transmitted
to them by some other IPC mechanism.
- Exception
| IConditionInvalid
| if there is any failure to create
the underlying system resources required to implement
the condition.
|
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
Overload 2
- Constructs a shared condition object, with the passed name.
public:
ISharedCondition(const char* keyName)
- This constructor creates a shared condition with the passed name. Any other processes which know this name can open this shared condition and
use it.
- keyName
- This is the name to give to the shared condition object. The default constructor does not accept a
name, and will build a unique name for you. This name may subsequently be queried and passed to other
processes via some other IPC mechanism if desired.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
Member Access
Access members of a shared condition object.
- keyName
public:
IString keyName() const
- Returns the key name for this condition object. Note that this is the name that you gave, but this is not necessarily
the host specific name that actually gets used internally. The naming scheme of the host operating system often
requires some ornamentation.
- Return
- The key name of this shared condition object, in an IString object by value.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
Static methods
Perform static operations on shared conditions.
- exists
public:
static bool exists(const char* keyName)
- Checks to see whether the named condition exists or not. Note that, as with any such shared resource
in a multitasking world, you cannot always assume that it will not come into existence after this call
but before you can do something based on the result. So only consider it advisory.
- keyName
- The name to check for. If a condition by this name exists, true is returned.
- Return
- true if the condition exists, else false.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
Waiting and signalling
Wait on a shared condition or signal other threads which are waiting on a shared condition.
- broadcast
public:
virtual void broadcast()
- Allows all threads, currently waiting on this condition, to return from their wait operations. In some platform
implementations, threads entering wait() while the broadcast is being done might also be allowed to pass
on through, i.e. it does not take a snapshot of waiting threads necessarily.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
- signal
- Signals the condition, which allows one other thread return from a
public:
virtual void signal()
- Signals the condition, which allows one waiting thread to return from a wait on the condition. Only
one thread is allowed through, never more. If no threads are waiting, then this has no effect. So
signal() is a pulse type operation, i.e. it does not remain signaled.
- Exception
| IConditionInvalid
| if any errors occur in the host APIs
required to perform the signaling operation.
|
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
- wait
- Waits for the condition to be signaled or broadcast by another thread or process. An optional timeout
can be provided, which defaults to an infinite wait if none is explicitly given.
Overload 1
public:
virtual bool wait(IResourceLock& alock, long timeOut = - 1)
- This version accepts a resource lock object. It is assumed that the calling thread owns this resource lock. The lock will be temporarily release while
the calling thread is blocked on the wait call. When the calling thread is released, either by timeout or a signal or broadcast from another thread, the
lock will be reaquired before returning.
- aLock
- is a resource lock object which will be unlocked while the thread waits. It must be owned by the calling thread.
- timeOut
- The number of milliseconds to wait for the condition to become signaled. Defaults to -1, which means wait forever.
- Return
- true if the wait succeeded, or false if it timed out. Any other error will result in an IConditionInvalid exception.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
Overload 2
public:
virtual bool wait(long timeOut = - 1)
- This version does not accept a resource lock object. It just waits for a signal or broadcast from another thread, or times out if one does not arrive before
the passed timeout period.
- timeOut
- The number of milliseconds to wait for the condition to become signaled. Defaults to -1, which
means wait forever.
- Return
- true if the wait succeeded, or false if it timed out. Any other error will result in an IConditionInvalid exception.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
ISharedCondition - Inherited Member Functions and Data
Inherited Public Functions
- ICondition
-
virtual ~ICondition()
virtual void broadcast() = 0
static void Relock(IResourceLock&, long times)
virtual void signal() = 0
static long Unlock(IResourceLock&)
virtual bool
wait( IResourceLock& alock,
long timeOut = - 1 ) = 0
virtual bool wait(long timeOut = - 1) = 0
Inherited Public Data
Inherited Protected Functions
- ICondition
-
Inherited Protected Data