mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-07 05:06:37 +02:00
Fixing mutex-unlock! on a condition variable to both unlock and block.
This commit is contained in:
parent
1ab1008f20
commit
1aff449a48
1 changed files with 24 additions and 25 deletions
|
@ -218,8 +218,7 @@ sexp sexp_mutex_lock (sexp ctx, sexp self, sexp_sint_t n, sexp mutex, sexp timeo
|
|||
|
||||
sexp sexp_mutex_unlock (sexp ctx, sexp self, sexp_sint_t n, sexp mutex, sexp condvar, sexp timeout) {
|
||||
sexp ls1, ls2;
|
||||
if (sexp_not(condvar)) {
|
||||
/* normal unlock - always succeeds, just need to unblock threads */
|
||||
/* first unlock and unblock threads */
|
||||
if (sexp_truep(sexp_mutex_lockp(mutex))) {
|
||||
sexp_mutex_lockp(mutex) = SEXP_FALSE;
|
||||
sexp_mutex_thread(mutex) = ctx;
|
||||
|
@ -240,14 +239,14 @@ sexp sexp_mutex_unlock (sexp ctx, sexp self, sexp_sint_t n, sexp mutex, sexp con
|
|||
break;
|
||||
}
|
||||
}
|
||||
return SEXP_TRUE;
|
||||
} else {
|
||||
/* wait on condition var */
|
||||
if (sexp_truep(condvar)) {
|
||||
/* wait on condition var if specified */
|
||||
sexp_context_waitp(ctx) = 1;
|
||||
sexp_context_event(ctx) = condvar;
|
||||
sexp_insert_timed(ctx, ctx, timeout);
|
||||
return SEXP_FALSE;
|
||||
}
|
||||
return SEXP_TRUE;
|
||||
}
|
||||
|
||||
/**************************** condition variables *************************/
|
||||
|
|
Loading…
Add table
Reference in a new issue