add condition-mutex and condition-name
This commit is contained in:
parent
9dad5e59e3
commit
1fb339bccd
2 changed files with 45 additions and 0 deletions
27
src/thread.c
27
src/thread.c
|
@ -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);
|
||||
|
|
|
@ -188,4 +188,22 @@
|
|||
(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
|
||||
|
|
Loading…
Add table
Reference in a new issue