Class: GuardCondition

vortexdds~GuardCondition()

A user-triggerable condition for interrupting Waitsets.

A GuardCondition, when attached to a Waitset, enables you to interrupt an asynchronous Waitset.wait() operation by calling the GuardCondition.trigger() method.

Note that DDS resources and memory consumed by conditions cannot be automatically reclaimed by the NodeJS engine. Conditions are automatically deleted when the parent entity is deleted. Otherwise, when your application is finished with a Condition, you may call Condition.delete() to release these DDS resources.

Constructor

new GuardCondition()

Create a guard condition.

Extends:
Example
const dds = require('vortexdds');
const ws = new dds.Waitset();
const guard = new dds.GuardCondition();
ws.attach(guard);
// ws.attach(other conditions);
ws.wait()
.then(triggeredConds => {
    for(const cond of triggeredConds) {
        if(cond === guard) {
            // guard was triggered
        }
    }
})
.catch(err => {
    // wait set error, including timeout
});

// sometime later, cause the wait set to trigger.
guard.trigger();

Extends

Methods

delete()

Releases DDS resources associated with the condition.

Once deleted, the condition can no longer be used.

Note that DDS resources and memory consumed by conditions cannot be automatically reclaimed by the NodeJS engine. Conditions are automatically deleted when the parent entity is deleted. Otherwise, when your application is finished with a Condition, you may call this method to release these DDS resources.

Overrides:

reset()

Resets the guard condition so that it is no longer triggered..

trigger()

Trigger the guard condition, forcing any Waitset.wait() operation to which the guard was attached to complete.

triggered() → {boolean}

Checks whether the condition is triggered or not.

Overrides:
Returns:
Type
boolean