* Getting rid of the necessity for cleaning up initialized ConditionalVariables
in uninit_condition_variables(). This method and its counterpart init_condition_variables() will be removed, once the need for the sConditionVariableHash will be eliminated. * Now every initialized ConditionalVariable gets removed right after it is no longer needed. Ingo what do you think? * This behaviour matches with the FreeBSD way, where a conditional variable gets assigned to a sleepqueue only when needed, and is removed from that sleepqueue the moment the condition is met. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34427 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -54,20 +54,7 @@ init_condition_variables()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
uninit_condition_variables()
|
uninit_condition_variables() {}
|
||||||
{
|
|
||||||
ConditionVariableHashDefinition definition;
|
|
||||||
InterruptsSpinLocker hashLocker(sConditionVariablesLock);
|
|
||||||
ConditionVariable* variable = sConditionVariableHash.Clear(true);
|
|
||||||
hashLocker.Unlock();
|
|
||||||
|
|
||||||
while (variable != NULL) {
|
|
||||||
ConditionVariable* next = definition.GetLink(variable);
|
|
||||||
variable->Unpublish();
|
|
||||||
delete variable;
|
|
||||||
variable = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
|
|
||||||
struct cv {
|
struct cv {
|
||||||
int dummy;
|
const char* description;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
void cv_init(struct cv* conditionVariable, const char* description)
|
void cv_init(struct cv* conditionVariable, const char* description)
|
||||||
{
|
{
|
||||||
_cv_init(conditionVariable, description);
|
conditionVariable->description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -26,17 +26,25 @@ int cv_timedwait(struct cv* conditionVariable, struct mtx* mutex, int timeout)
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
_cv_init(conditionVariable, conditionVariable->description);
|
||||||
|
|
||||||
mtx_unlock(mutex);
|
mtx_unlock(mutex);
|
||||||
status = _cv_timedwait_unlocked(conditionVariable, timeout);
|
status = _cv_timedwait_unlocked(conditionVariable, timeout);
|
||||||
mtx_lock(mutex);
|
mtx_lock(mutex);
|
||||||
|
|
||||||
|
_cv_destroy(conditionVariable);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void cv_wait(struct cv* conditionVariable, struct mtx* mutex)
|
void cv_wait(struct cv* conditionVariable, struct mtx* mutex)
|
||||||
{
|
{
|
||||||
|
_cv_init(conditionVariable, conditionVariable->description);
|
||||||
|
|
||||||
mtx_unlock(mutex);
|
mtx_unlock(mutex);
|
||||||
_cv_wait_unlocked(conditionVariable);
|
_cv_wait_unlocked(conditionVariable);
|
||||||
mtx_lock(mutex);
|
mtx_lock(mutex);
|
||||||
|
|
||||||
|
_cv_destroy(conditionVariable);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user