diff options
| author | Tom Tromey | 2012-08-15 13:11:22 -0600 |
|---|---|---|
| committer | Tom Tromey | 2012-08-15 13:11:22 -0600 |
| commit | 51100bb8d36f68842ab55fd0501af56dfc58cc51 (patch) | |
| tree | 6c94b7f893304276b43c57bd12eff92d914a7cd2 /src/data.c | |
| parent | 1dcacbc64721b1a4de58aa36460b0a39e766be63 (diff) | |
| download | emacs-51100bb8d36f68842ab55fd0501af56dfc58cc51.tar.gz emacs-51100bb8d36f68842ab55fd0501af56dfc58cc51.zip | |
This supplies the mutex implementation for Emacs Lisp.
A lisp mutex is implemented using a condition variable, so that we can
interrupt a mutex-lock operation by calling thread-signal on the
blocking thread. I did things this way because pthread_mutex_lock
can't readily be interrupted.
Diffstat (limited to 'src/data.c')
| -rw-r--r-- | src/data.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/data.c b/src/data.c index fd2194fe1ae..b47c2d12aff 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -94,7 +94,7 @@ static Lisp_Object Qchar_table, Qbool_vector, Qhash_table; | |||
| 94 | static Lisp_Object Qsubrp, Qmany, Qunevalled; | 94 | static Lisp_Object Qsubrp, Qmany, Qunevalled; |
| 95 | Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; | 95 | Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; |
| 96 | static Lisp_Object Qdefun; | 96 | static Lisp_Object Qdefun; |
| 97 | Lisp_Object Qthread; | 97 | Lisp_Object Qthread, Qmutex; |
| 98 | 98 | ||
| 99 | Lisp_Object Qinteractive_form; | 99 | Lisp_Object Qinteractive_form; |
| 100 | 100 | ||
| @@ -214,6 +214,8 @@ for example, (type-of 1) returns `integer'. */) | |||
| 214 | return Qfont_object; | 214 | return Qfont_object; |
| 215 | if (THREADP (object)) | 215 | if (THREADP (object)) |
| 216 | return Qthread; | 216 | return Qthread; |
| 217 | if (MUTEXP (object)) | ||
| 218 | return Qmutex; | ||
| 217 | return Qvector; | 219 | return Qvector; |
| 218 | 220 | ||
| 219 | case Lisp_Float: | 221 | case Lisp_Float: |
| @@ -471,6 +473,15 @@ DEFUN ("threadp", Fthreadp, Sthreadp, 1, 1, 0, | |||
| 471 | return Qnil; | 473 | return Qnil; |
| 472 | } | 474 | } |
| 473 | 475 | ||
| 476 | DEFUN ("mutexp", Fmutexp, Smutexp, 1, 1, 0, | ||
| 477 | doc: /* Return t if OBJECT is a mutex. */) | ||
| 478 | (Lisp_Object object) | ||
| 479 | { | ||
| 480 | if (MUTEXP (object)) | ||
| 481 | return Qt; | ||
| 482 | else | ||
| 483 | return Qnil; | ||
| 484 | } | ||
| 474 | 485 | ||
| 475 | /* Extract and set components of lists */ | 486 | /* Extract and set components of lists */ |
| 476 | 487 | ||
| @@ -3105,6 +3116,7 @@ syms_of_data (void) | |||
| 3105 | DEFSYM (Qbool_vector, "bool-vector"); | 3116 | DEFSYM (Qbool_vector, "bool-vector"); |
| 3106 | DEFSYM (Qhash_table, "hash-table"); | 3117 | DEFSYM (Qhash_table, "hash-table"); |
| 3107 | DEFSYM (Qthread, "thread"); | 3118 | DEFSYM (Qthread, "thread"); |
| 3119 | DEFSYM (Qmutex, "mutex"); | ||
| 3108 | /* Used by Fgarbage_collect. */ | 3120 | /* Used by Fgarbage_collect. */ |
| 3109 | DEFSYM (Qinterval, "interval"); | 3121 | DEFSYM (Qinterval, "interval"); |
| 3110 | DEFSYM (Qmisc, "misc"); | 3122 | DEFSYM (Qmisc, "misc"); |
| @@ -3148,6 +3160,7 @@ syms_of_data (void) | |||
| 3148 | defsubr (&Sbyte_code_function_p); | 3160 | defsubr (&Sbyte_code_function_p); |
| 3149 | defsubr (&Schar_or_string_p); | 3161 | defsubr (&Schar_or_string_p); |
| 3150 | defsubr (&Sthreadp); | 3162 | defsubr (&Sthreadp); |
| 3163 | defsubr (&Smutexp); | ||
| 3151 | defsubr (&Scar); | 3164 | defsubr (&Scar); |
| 3152 | defsubr (&Scdr); | 3165 | defsubr (&Scdr); |
| 3153 | defsubr (&Scar_safe); | 3166 | defsubr (&Scar_safe); |