About
A condition variable is used to wake a waiting thread to perform some action. It is typically used together with custom threads, see Threads Manual.
Condition
A condition variable is based on maxon::ConditionVariableInterface:
- Warning
- Waiting for a condition variable in a job might result in a deadlock. Consider using LazyInit or LazyInitThreaded for initialization instead.
A condition variable can have multiple dependencies. This means that Set()
must be called multiple times:
A condition variable is typically used as a member variable of a custom thread:
{
public:
~ExampleThread() { }
{
}
maxon::Result<
void> operator ()()
{
{
if (_condition.Wait(timeValue))
{
_condition.Clear();
}
}
}
void Action()
{
_condition.Set();
}
private:
maxon::ConditionVariableRef _condition;
};
Timer value in seconds.
Definition: timevalue.h:411
char Char
signed 8 bit character
Definition: apibase.h:184
static auto Create(ARGS &&... args)
Definition: apibase.h:2773
return OK
Definition: apibase.h:2690
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
const Char * GetName() const
Definition: job.h:179
Bool IsCancelled() const
Definition: job.h:292
The maxon namespace contains all declarations of the MAXON API.
Definition: autoweight.h:14
#define iferr_scope
Definition: resultbase.h:1384
#define iferr_return
Definition: resultbase.h:1519
This example thread can be used like this:
if (!g_exampleThread)
{
}
if (g_exampleThread)
{
g_exampleThread->Action();
}
Further Reading