summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2016-11-05 19:39:12 +0100
committerAndy Wingo <wingo@pobox.com>2016-11-05 19:39:12 +0100
commit03ffd726df81731a0b1738bf2bb4842ea730c680 (patch)
treeefad5f316cf22e0c916528ce6f7478aef26b5847
parent8d907758a0a0d4e4a02ccb91e56ba6e42c6a747f (diff)
downloadguile-03ffd726df81731a0b1738bf2bb4842ea730c680.tar.gz
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.
-rw-r--r--libguile/deprecated.c15
-rw-r--r--libguile/deprecated.h1
-rw-r--r--libguile/threads.c27
-rw-r--r--libguile/threads.h2
4 files changed, 27 insertions, 18 deletions
diff --git a/libguile/deprecated.c b/libguile/deprecated.c
index d2e01f3b7..6da604e42 100644
--- a/libguile/deprecated.c
+++ b/libguile/deprecated.c
@@ -700,6 +700,21 @@ scm_make_mutex_with_flags (SCM flags)
}
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)
{
scm_c_issue_deprecation_warning
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);