| IGLib 1.4 The IGLib base library for development of numerical, technical and business applications.

- Main Page
- Namespaces
- Classes
- Files
- Directories

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Private Attributes

# IG::Lib::WaitCondition Class Reference

Provides a framework for blocking execution until the specified condition becomes satisfied. Function Wait() does that. The function continuously check the unblocking condition until it becomes satisfied, sleeping a certain amount of time between consecutive checks. Time plan of checks (i.e. the amount of sleepin time between them) can be adjusted by public properties SleepFirst, MinSleepMs, MaxSleepMs, and MaxRelativeLatency. These properties can be adjusted while waiting. Blocking condition is evaluated by the (public) function Condition() and can be adjusted in one of the following ways:

- by setting the delegate ConditionDelegate.
- by overriding the protected ConditionFunction() in a derived class and setting ConditionDelegate to null.
- by overriding the Condition() function itself.

More...
Inheritance diagram for IG::Lib::WaitCondition:
[legend]
Collaboration diagram for IG::Lib::WaitCondition:
[legend]

List of all members.

## Public Member Functions
| WaitCondition ()
| Creates event waiter with properties initialized to default values.
| WaitCondition (int minSleepMs, double maxRelativeLatency)
| Creates event waiter with properties initialized to specified values (or to default valuse for those parameters that are not specified).
| WaitCondition (int minSleepMs, int maxSleepMs, double maxRelativeLatency, bool sleepFirst)
| Creates event waiter with properties initialized to specified values (or to default valuse for those parameters that are not specified).
override bool | Condition ()
| Function that returns true if unblocking condition is satisfied, and false otherwise. If the condition delegate is set then the delegate is used to evaluate the condition, otherwise the protected method ConditionFunction() is used. The condition can therefore be adjusted in one of the following ways: by setting the ConditionDelegate field by overriding the ConditionFunction and leaving ConditionDelegate null.
override void | Wait ()
| Blocks until the specified condition gets satisfied. See class description for details.
override string | ToString ()
## Protected Member Functions
virtual void | InitWaitCondition ()
| Initializes object properties with default values.
virtual void | InitWaitCondition (int minSleepMs, double maxRelativeLatency)
| Initializes blocking parameters to the specified values (or to default values for those parameters that are not specified).
virtual void | InitWaitCondition (int minSleepMs, int maxSleepMs, double maxRelativeLatency, bool sleepFirst)
| Initializes blocking parameters.
virtual bool | ConditionFunction ()
| Evaluates blocking condition in the case that the condition delegate is not specified.
## Protected Attributes
ConditionDelegateBase | _conditionDelegate = null
int | _minSleepMs = 1
StopWatch | _timer = null
## Properties
virtual ConditionDelegateBase | ConditionDelegate`[get, set]`
| Contains function that is called to evaluate the unblocking condition. If this delegate is set and Condition() is not overridden then the delegate is used to check whether the unblocking condition is satisfied.
virtual int | MinSleepMs`[get, set]`
| Minimal sleeping time, in milliseconds, between successive condition checks. If less than 0 then minimal sleeping time is not specified, so there may be no sleeping.
virtual int | MaxSleepMs`[get, set]`
| Maximal sleeping time, in milliseconds, between successive condition checks. If less than 0 then maximal sleeping time is not specified and sleeping interval is not bounded above. If set to 0 then no sleeping will be performed between successive checks (max. sleeping time overrides the minimal sleeping time).
virtual double | MaxRelativeLatency`[get, set]`
| Maximal relative latency of waiting procedure. Sleeping time chosen between two successive condition check willl be chosen smaller or equal to total elapsed waiting time multiplied by this number. If less than 0 then maximal relative latency is not specified. If minimal sleeping time is specified then it overrides the sleeping time calculated according to this parameter.
virtual bool | SleepFirst`[get, set]`
| If true and if minimal sleeping time is larger than 0, then sleep for minimal sleeping time will be performed before the first check for unblocking condition.
StopWatch | Timer`[get]`
| Timer that measures the total time elapsed when waiting for fulfillment of unblocking condition. Used to evaluate appropriate sleeping times that will not cause too much latency.
## Private Attributes
int | _maxSleepMs = -1
double | _maxRelativeLatency = 0.05
bool | _sleepFirst = false

## Detailed Description

Provides a framework for blocking execution until the specified condition becomes satisfied. Function Wait() does that. The function continuously check the unblocking condition until it becomes satisfied, sleeping a certain amount of time between consecutive checks. Time plan of checks (i.e. the amount of sleepin time between them) can be adjusted by public properties SleepFirst, MinSleepMs, MaxSleepMs, and MaxRelativeLatency. These properties can be adjusted while waiting. Blocking condition is evaluated by the (public) function Condition() and can be adjusted in one of the following ways:

- by setting the delegate ConditionDelegate.
- by overriding the protected ConditionFunction() in a derived class and setting ConditionDelegate to null.
- by overriding the Condition() function itself.

$A Igor Jun10;

## Constructor & Destructor Documentation

IG::Lib::WaitCondition::WaitCondition | ( |  | ) | `[inline]`

Creates event waiter with properties initialized to default values.

IG::Lib::WaitCondition::WaitCondition | ( | int | minSleepMs,
|  | double | maxRelativeLatency
| ) |  | `[inline]`

Creates event waiter with properties initialized to specified values (or to default valuse for those parameters that are not specified).

IG::Lib::WaitCondition::WaitCondition | ( | int | minSleepMs,
|  | int | maxSleepMs,
|  | double | maxRelativeLatency,
|  | bool | sleepFirst
| ) |  | `[inline]`

Creates event waiter with properties initialized to specified values (or to default valuse for those parameters that are not specified).

## Member Function Documentation

virtual void IG::Lib::WaitCondition::InitWaitCondition | ( |  | ) | `[inline, protected, virtual]`

Initializes object properties with default values.

virtual void IG::Lib::WaitCondition::InitWaitCondition | ( | int | minSleepMs,
|  | double | maxRelativeLatency
| ) |  | `[inline, protected, virtual]`

Initializes blocking parameters to the specified values (or to default values for those parameters that are not specified).

virtual void IG::Lib::WaitCondition::InitWaitCondition | ( | int | minSleepMs,
|  | int | maxSleepMs,
|  | double | maxRelativeLatency,
|  | bool | sleepFirst
| ) |  | `[inline, protected, virtual]`

Initializes blocking parameters.

override bool IG::Lib::WaitCondition::Condition | ( |  | ) | `[inline]`

Function that returns true if unblocking condition is satisfied, and false otherwise. If the condition delegate is set then the delegate is used to evaluate the condition, otherwise the protected method ConditionFunction() is used. The condition can therefore be adjusted in one of the following ways:

- by setting the ConditionDelegate field
- by overriding the ConditionFunction and leaving ConditionDelegate null.

Implements IG::Lib::IWaitCondition.

Reimplemented in IG::Lib::WaitFileEventLatenceBase, IG::Lib::WaitFileCreationLatence, IG::Lib::WaitFileRemovalLatence, IG::Lib::WaitDirectoryCreationLatence, and IG::Lib::WaitDirectoryRemovalLatence.

virtual bool IG::Lib::WaitCondition::ConditionFunction | ( |  | ) | `[inline, protected, virtual]`

Evaluates blocking condition in the case that the condition delegate is not specified.

Returns:
  True if the unblocking condition is satisfied (such that the thread will continue with execution) after the condition is being evaluated.

Reimplemented in IG::Lib::WaitFileEventLatenceBase.

override void IG::Lib::WaitCondition::Wait | ( |  | ) | `[inline]`

Blocks until the specified condition gets satisfied. See class description for details.

This method will normally not be overridden, except with intention to change the condition check time plan. When overriding, use the original method as template.

Implements IG::Lib::IWaitCondition.

override string IG::Lib::WaitCondition::ToString | ( |  | ) | `[inline]`

## Member Data Documentation

ConditionDelegateBase IG::Lib::WaitCondition::_conditionDelegate = null`[protected]`

int IG::Lib::WaitCondition::_minSleepMs = 1`[protected]`

int IG::Lib::WaitCondition::_maxSleepMs = -1`[private]`

double IG::Lib::WaitCondition::_maxRelativeLatency = 0.05`[private]`

bool IG::Lib::WaitCondition::_sleepFirst = false`[private]`

StopWatch IG::Lib::WaitCondition::_timer = null`[protected]`

## Property Documentation

virtual ConditionDelegateBase IG::Lib::WaitCondition::ConditionDelegate`[get, set]`

Contains function that is called to evaluate the unblocking condition. If this delegate is set and Condition() is not overridden then the delegate is used to check whether the unblocking condition is satisfied.

Reimplemented in IG::Lib::WaitFileEventLatenceBase.

virtual int IG::Lib::WaitCondition::MinSleepMs`[get, set]`

Minimal sleeping time, in milliseconds, between successive condition checks. If less than 0 then minimal sleeping time is not specified, so there may be no sleeping.

virtual int IG::Lib::WaitCondition::MaxSleepMs`[get, set]`

Maximal sleeping time, in milliseconds, between successive condition checks. If less than 0 then maximal sleeping time is not specified and sleeping interval is not bounded above. If set to 0 then no sleeping will be performed between successive checks (max. sleeping time overrides the minimal sleeping time).

virtual double IG::Lib::WaitCondition::MaxRelativeLatency`[get, set]`

Maximal relative latency of waiting procedure. Sleeping time chosen between two successive condition check willl be chosen smaller or equal to total elapsed waiting time multiplied by this number. If less than 0 then maximal relative latency is not specified. If minimal sleeping time is specified then it overrides the sleeping time calculated according to this parameter.

virtual bool IG::Lib::WaitCondition::SleepFirst`[get, set]`

If true and if minimal sleeping time is larger than 0, then sleep for minimal sleeping time will be performed before the first check for unblocking condition.

StopWatch IG::Lib::WaitCondition::Timer`[get, protected]`

Timer that measures the total time elapsed when waiting for fulfillment of unblocking condition. Used to evaluate appropriate sleeping times that will not cause too much latency.

The documentation for this class was generated from the following file:

- WaitCondition.cs

All Classes Namespaces Files Functions Variables Enumerations Properties Events