mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
(to_timespec): Change 1000000 multiplier to
1000000000. (unchecked_unlock_sym, allow_external_unlock_sym, recursive_sym): Use SCM_SYMBOL. (scm_make_mutex_with_flags): When raising unsupported option error, report what the unsupported option was. (fat_mutex_unlock): When raising errors, unlock m->lock first. (fat_cond_timedwait): Removed. (scm_timed_wait_condition_variable): Call fat_mutex_unlock directly instead of via fat_cond_timedwait.
This commit is contained in:
parent
9c9b203b80
commit
2a1d06886e
2 changed files with 30 additions and 21 deletions
|
@ -1,3 +1,19 @@
|
||||||
|
2008-03-24 Neil Jerram <neil@ossau.uklinux.net>
|
||||||
|
|
||||||
|
Applying patch from Julian Graham, containing minor fixes to his
|
||||||
|
thread enhancements:
|
||||||
|
|
||||||
|
* threads.c (to_timespec): Change 1000000 multiplier to
|
||||||
|
1000000000.
|
||||||
|
(unchecked_unlock_sym, allow_external_unlock_sym,
|
||||||
|
recursive_sym): Use SCM_SYMBOL.
|
||||||
|
(scm_make_mutex_with_flags): When raising unsupported option
|
||||||
|
error, report what the unsupported option was.
|
||||||
|
(fat_mutex_unlock): When raising errors, unlock m->lock first.
|
||||||
|
(fat_cond_timedwait): Removed.
|
||||||
|
(scm_timed_wait_condition_variable): Call fat_mutex_unlock
|
||||||
|
directly instead of via fat_cond_timedwait.
|
||||||
|
|
||||||
2008-03-10 Ludovic Courtès <ludo@gnu.org>
|
2008-03-10 Ludovic Courtès <ludo@gnu.org>
|
||||||
|
|
||||||
* eval.c, filesys.c: Enclose `alloca' blob in `#ifndef alloca',
|
* eval.c, filesys.c: Enclose `alloca' blob in `#ifndef alloca',
|
||||||
|
|
|
@ -74,7 +74,7 @@ to_timespec (SCM t, scm_t_timespec *waittime)
|
||||||
double sec = scm_c_truncate (time);
|
double sec = scm_c_truncate (time);
|
||||||
|
|
||||||
waittime->tv_sec = (long) sec;
|
waittime->tv_sec = (long) sec;
|
||||||
waittime->tv_nsec = (long) ((time - sec) * 1000000);
|
waittime->tv_nsec = (long) ((time - sec) * 1000000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1170,9 +1170,9 @@ SCM scm_make_mutex (void)
|
||||||
return scm_make_mutex_with_flags (SCM_EOL);
|
return scm_make_mutex_with_flags (SCM_EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SCM unchecked_unlock_sym;
|
SCM_SYMBOL (unchecked_unlock_sym, "unchecked-unlock");
|
||||||
static SCM allow_external_unlock_sym;
|
SCM_SYMBOL (allow_external_unlock_sym, "allow-external-unlock");
|
||||||
static SCM recursive_sym;
|
SCM_SYMBOL (recursive_sym, "recursive");
|
||||||
|
|
||||||
SCM_DEFINE (scm_make_mutex_with_flags, "make-mutex", 0, 0, 1,
|
SCM_DEFINE (scm_make_mutex_with_flags, "make-mutex", 0, 0, 1,
|
||||||
(SCM flags),
|
(SCM flags),
|
||||||
|
@ -1192,7 +1192,7 @@ SCM_DEFINE (scm_make_mutex_with_flags, "make-mutex", 0, 0, 1,
|
||||||
else if (scm_is_eq (flag, recursive_sym))
|
else if (scm_is_eq (flag, recursive_sym))
|
||||||
recursive = 1;
|
recursive = 1;
|
||||||
else
|
else
|
||||||
SCM_MISC_ERROR ("unsupported mutex option", SCM_EOL);
|
SCM_MISC_ERROR ("unsupported mutex option: ~a", scm_list_1 (flag));
|
||||||
ptr = SCM_CDR (ptr);
|
ptr = SCM_CDR (ptr);
|
||||||
}
|
}
|
||||||
return make_fat_mutex (recursive, unchecked_unlock, external_unlock);
|
return make_fat_mutex (recursive, unchecked_unlock, external_unlock);
|
||||||
|
@ -1378,10 +1378,16 @@ fat_mutex_unlock (SCM mutex, SCM cond,
|
||||||
if (scm_is_false (m->owner))
|
if (scm_is_false (m->owner))
|
||||||
{
|
{
|
||||||
if (!m->unchecked_unlock)
|
if (!m->unchecked_unlock)
|
||||||
scm_misc_error (NULL, "mutex not locked", SCM_EOL);
|
{
|
||||||
|
scm_i_pthread_mutex_unlock (&m->lock);
|
||||||
|
scm_misc_error (NULL, "mutex not locked", SCM_EOL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!m->allow_external_unlock)
|
else if (!m->allow_external_unlock)
|
||||||
scm_misc_error (NULL, "mutex not locked by current thread", SCM_EOL);
|
{
|
||||||
|
scm_i_pthread_mutex_unlock (&m->lock);
|
||||||
|
scm_misc_error (NULL, "mutex not locked by current thread", SCM_EOL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! (SCM_UNBNDP (cond)))
|
if (! (SCM_UNBNDP (cond)))
|
||||||
|
@ -1563,13 +1569,6 @@ SCM_DEFINE (scm_make_condition_variable, "make-condition-variable", 0, 0, 0,
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
static int
|
|
||||||
fat_cond_timedwait (SCM cond, SCM mutex,
|
|
||||||
const scm_t_timespec *waittime)
|
|
||||||
{
|
|
||||||
return fat_mutex_unlock (mutex, cond, waittime, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SCM_DEFINE (scm_timed_wait_condition_variable, "wait-condition-variable", 2, 1, 0,
|
SCM_DEFINE (scm_timed_wait_condition_variable, "wait-condition-variable", 2, 1, 0,
|
||||||
(SCM cv, SCM mx, SCM t),
|
(SCM cv, SCM mx, SCM t),
|
||||||
"Wait until @var{cond-var} has been signalled. While waiting, "
|
"Wait until @var{cond-var} has been signalled. While waiting, "
|
||||||
|
@ -1594,7 +1593,7 @@ SCM_DEFINE (scm_timed_wait_condition_variable, "wait-condition-variable", 2, 1,
|
||||||
waitptr = &waittime;
|
waitptr = &waittime;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fat_cond_timedwait (cv, mx, waitptr) ? SCM_BOOL_T : SCM_BOOL_F;
|
return fat_mutex_unlock (mx, cv, waitptr, 1) ? SCM_BOOL_T : SCM_BOOL_F;
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
@ -1997,12 +1996,6 @@ scm_init_threads ()
|
||||||
scm_set_smob_print (scm_tc16_mutex, fat_mutex_print);
|
scm_set_smob_print (scm_tc16_mutex, fat_mutex_print);
|
||||||
scm_set_smob_free (scm_tc16_mutex, fat_mutex_free);
|
scm_set_smob_free (scm_tc16_mutex, fat_mutex_free);
|
||||||
|
|
||||||
unchecked_unlock_sym =
|
|
||||||
scm_permanent_object (scm_from_locale_symbol ("unchecked-unlock"));
|
|
||||||
allow_external_unlock_sym =
|
|
||||||
scm_permanent_object (scm_from_locale_symbol ("allow-external-unlock"));
|
|
||||||
recursive_sym = scm_permanent_object (scm_from_locale_symbol ("recursive"));
|
|
||||||
|
|
||||||
scm_tc16_condvar = scm_make_smob_type ("condition-variable",
|
scm_tc16_condvar = scm_make_smob_type ("condition-variable",
|
||||||
sizeof (fat_cond));
|
sizeof (fat_cond));
|
||||||
scm_set_smob_mark (scm_tc16_condvar, fat_cond_mark);
|
scm_set_smob_mark (scm_tc16_condvar, fat_cond_mark);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue