]> git.eshelyaron.com Git - emacs.git/commitdiff
add condition-mutex and condition-name
authorTom Tromey <tromey@redhat.com>
Sun, 19 Aug 2012 09:31:57 +0000 (03:31 -0600)
committerTom Tromey <tromey@redhat.com>
Sun, 19 Aug 2012 09:31:57 +0000 (03:31 -0600)
src/thread.c
test/automated/threads.el

index b8ffb0662c30ca7cf01e556901c664793916e285..4c21418d1c35c3411fada8de208e2837241de115 100644 (file)
@@ -425,6 +425,31 @@ thread.  */)
   return Qnil;
 }
 
+DEFUN ("condition-mutex", Fcondition_mutex, Scondition_mutex, 1, 1, 0,
+       doc: /* Return the mutex associated with CONDITION.  */)
+  (Lisp_Object condition)
+{
+  struct Lisp_CondVar *cvar;
+
+  CHECK_CONDVAR (condition);
+  cvar = XCONDVAR (condition);
+
+  return cvar->mutex;
+}
+
+DEFUN ("condition-name", Fcondition_name, Scondition_name, 1, 1, 0,
+       doc: /* Return the name of CONDITION.
+If no name was given when CONDITION was created, return nil.  */)
+  (Lisp_Object condition)
+{
+  struct Lisp_CondVar *cvar;
+
+  CHECK_CONDVAR (condition);
+  cvar = XCONDVAR (condition);
+
+  return cvar->name;
+}
+
 void
 finalize_one_condvar (struct Lisp_CondVar *condvar)
 {
@@ -898,6 +923,8 @@ syms_of_threads (void)
   defsubr (&Smake_condition_variable);
   defsubr (&Scondition_wait);
   defsubr (&Scondition_notify);
+  defsubr (&Scondition_mutex);
+  defsubr (&Scondition_name);
 
   Qthreadp = intern_c_string ("threadp");
   staticpro (&Qthreadp);
index ce929fc0adda6f5a7c31f052d04c684d1f6e1e08..87e5eec218f3eb07fabbd475d00e3b0a19cfe4de 100644 (file)
   (should (eq (type-of (make-condition-variable (make-mutex)))
              'condition-variable)))
 
+(ert-deftest threads-condvar-mutex ()
+  "simple test of condition-mutex"
+  (should
+   (let ((m (make-mutex)))
+     (eq m (condition-mutex (make-condition-variable m))))))
+
+(ert-deftest threads-condvar-name ()
+  "simple test of condition-name"
+  (should
+     (eq nil (condition-name (make-condition-variable (make-mutex))))))
+
+(ert-deftest threads-condvar-name-2 ()
+  "another simple test of condition-name"
+  (should
+     (string= "hi bob"
+             (condition-name (make-condition-variable (make-mutex)
+                                                      "hi bob")))))
+
 ;;; threads.el ends here