diff --git a/libguile/deprecated.c b/libguile/deprecated.c index d2e01f3b7..6da604e42 100644 --- a/libguile/deprecated.c +++ b/libguile/deprecated.c @@ -699,6 +699,21 @@ scm_make_mutex_with_flags (SCM flags) return scm_make_mutex_with_kind (kind); } +SCM +scm_lock_mutex_timed (SCM m, SCM timeout, SCM owner) +{ + scm_c_issue_deprecation_warning + ("'scm_lock_mutex_timed' is deprecated. " + "Use 'scm_timed_lock_mutex' instead."); + + if (!SCM_UNBNDP (owner) && !scm_is_false (owner)) + scm_c_issue_deprecation_warning + ("The 'owner' argument to 'scm_lock_mutex_timed' is deprecated. " + "Use SRFI-18 directly if you need this concept."); + + return scm_timed_lock_mutex (m, timeout); +} + SCM scm_unlock_mutex_timed (SCM mx, SCM cond, SCM timeout) { diff --git a/libguile/deprecated.h b/libguile/deprecated.h index 5948fc512..211266f6d 100644 --- a/libguile/deprecated.h +++ b/libguile/deprecated.h @@ -240,6 +240,7 @@ SCM_DEPRECATED void scm_dynwind_critical_section (SCM mutex); SCM_DEPRECATED SCM scm_make_mutex_with_flags (SCM flags); SCM_DEPRECATED SCM scm_unlock_mutex_timed (SCM mx, SCM cond, SCM timeout); +SCM_DEPRECATED SCM scm_lock_mutex_timed (SCM m, SCM timeout, SCM owner); diff --git a/libguile/threads.c b/libguile/threads.c index d7295bc9f..0da9de1ff 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -987,7 +987,8 @@ scm_cancel_thread (SCM thread) return SCM_UNSPECIFIED; } -SCM scm_join_thread (SCM thread) +SCM +scm_join_thread (SCM thread) { return scm_join_thread_timed (thread, SCM_UNDEFINED, SCM_UNDEFINED); } @@ -1201,20 +1202,17 @@ fat_mutex_lock (SCM mutex, scm_t_timespec *timeout, int *ret) return err; } -SCM scm_lock_mutex (SCM mx) +SCM +scm_lock_mutex (SCM mx) { - return scm_lock_mutex_timed (mx, SCM_UNDEFINED, SCM_UNDEFINED); + return scm_timed_lock_mutex (mx, SCM_UNDEFINED); } -SCM_DEFINE (scm_lock_mutex_timed, "lock-mutex", 1, 2, 0, - (SCM m, SCM timeout, SCM owner), +SCM_DEFINE (scm_timed_lock_mutex, "lock-mutex", 1, 1, 0, + (SCM m, SCM timeout), "Lock mutex @var{m}. If the mutex is already locked, the calling\n" - "thread blocks until the mutex becomes available. The function\n" - "returns when the calling thread owns the lock on @var{m}.\n" - "Locking a mutex that a thread already owns will succeed right\n" - "away and will not block the thread. That is, Guile's mutexes\n" - "are @emph{recursive}.") -#define FUNC_NAME s_scm_lock_mutex_timed + "thread blocks until the mutex becomes available.") +#define FUNC_NAME s_scm_timed_lock_mutex { SCM exception; int ret = 0; @@ -1228,11 +1226,6 @@ SCM_DEFINE (scm_lock_mutex_timed, "lock-mutex", 1, 2, 0, waittime = &cwaittime; } - if (!SCM_UNBNDP (owner) && !scm_is_false (owner)) - scm_c_issue_deprecation_warning - ("The 'owner' argument to lock-mutex is deprecated. Use SRFI-18 " - "directly if you need this concept."); - exception = fat_mutex_lock (m, waittime, &ret); if (!scm_is_false (exception)) scm_ithrow (SCM_CAR (exception), scm_list_1 (SCM_CDR (exception)), 1); @@ -1264,7 +1257,7 @@ scm_dynwind_lock_mutex (SCM mutex) SCM scm_try_mutex (SCM mutex) { - return scm_lock_mutex_timed (mutex, SCM_INUM0, SCM_UNDEFINED); + return scm_timed_lock_mutex (mutex, SCM_INUM0); } /*** Fat condition variables */ diff --git a/libguile/threads.h b/libguile/threads.h index 1da7bbf4a..ce8148f4e 100644 --- a/libguile/threads.h +++ b/libguile/threads.h @@ -152,7 +152,7 @@ SCM_API SCM scm_make_mutex (void); SCM_API SCM scm_make_recursive_mutex (void); SCM_API SCM scm_make_mutex_with_kind (SCM kind); SCM_API SCM scm_lock_mutex (SCM m); -SCM_API SCM scm_lock_mutex_timed (SCM m, SCM timeout, SCM owner); +SCM_API SCM scm_timed_lock_mutex (SCM m, SCM timeout); SCM_API void scm_dynwind_lock_mutex (SCM mutex); SCM_API SCM scm_try_mutex (SCM m); SCM_API SCM scm_unlock_mutex (SCM m);