1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

scm_timed_lock_mutex replaces scm_lock_mutex_timed

* libguile/deprecated.h:
* libguile/deprecated.c (scm_lock_mutex_timed): Deprecate.
* libguile/threads.h:
* libguile/threads.c (scm_timed_lock_mutex): New function.
  (scm_join_thread): Fix formatting.
  (scm_lock_mutex): Fix formatting and update to scm_timed_lock_mutex
  change.
  (scm_try_mutex): Update to scm_timed_lock_mutex.
This commit is contained in:
Andy Wingo 2016-11-05 19:39:12 +01:00
parent 8d907758a0
commit 03ffd726df
4 changed files with 27 additions and 18 deletions

View file

@ -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)
{

View file

@ -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);

View file

@ -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 */

View file

@ -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);