diff options
| author | Tom Tromey | 2012-08-15 13:09:32 -0600 |
|---|---|---|
| committer | Tom Tromey | 2012-08-15 13:09:32 -0600 |
| commit | 1dcacbc64721b1a4de58aa36460b0a39e766be63 (patch) | |
| tree | 98a07fba97225221d3bcfab970070b5a6a6564d6 /src/thread.h | |
| parent | 60a9d2a7728895c1a5bfbc37c3bfa8fde35abe61 (diff) | |
| download | emacs-1dcacbc64721b1a4de58aa36460b0a39e766be63.tar.gz emacs-1dcacbc64721b1a4de58aa36460b0a39e766be63.zip | |
This adds most of the thread features visible to emacs lisp.
I roughly followed the Bordeaux threads API:
http://trac.common-lisp.net/bordeaux-threads/wiki/ApiDocumentation
... but not identically. In particular I chose not to implement
interrupt-thread or destroy-thread, but instead a thread-signalling
approach.
I'm still undecided about *default-special-bindings* (which I did not
implement). I think it would be more emacs-like to capture the let
bindings at make-thread time, but IIRC Stefan didn't like this idea
the first time around.
There are one or two semantics issues pointed out in the patch where I
could use some advice.
Diffstat (limited to 'src/thread.h')
| -rw-r--r-- | src/thread.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/thread.h b/src/thread.h index df26b887d1f..3b533316817 100644 --- a/src/thread.h +++ b/src/thread.h | |||
| @@ -34,6 +34,16 @@ struct thread_state | |||
| 34 | Lisp_Object m_saved_last_thing_searched; | 34 | Lisp_Object m_saved_last_thing_searched; |
| 35 | #define saved_last_thing_searched (current_thread->m_saved_last_thing_searched) | 35 | #define saved_last_thing_searched (current_thread->m_saved_last_thing_searched) |
| 36 | 36 | ||
| 37 | /* The thread's name. */ | ||
| 38 | Lisp_Object name; | ||
| 39 | |||
| 40 | /* The thread's function. */ | ||
| 41 | Lisp_Object function; | ||
| 42 | |||
| 43 | /* If non-nil, this thread has been signalled. */ | ||
| 44 | Lisp_Object error_symbol; | ||
| 45 | Lisp_Object error_data; | ||
| 46 | |||
| 37 | /* m_gcprolist must be the first non-lisp field. */ | 47 | /* m_gcprolist must be the first non-lisp field. */ |
| 38 | /* Recording what needs to be marked for gc. */ | 48 | /* Recording what needs to be marked for gc. */ |
| 39 | struct gcpro *m_gcprolist; | 49 | struct gcpro *m_gcprolist; |
| @@ -142,6 +152,18 @@ struct thread_state | |||
| 142 | /*re_char*/ unsigned char *m_whitespace_regexp; | 152 | /*re_char*/ unsigned char *m_whitespace_regexp; |
| 143 | #define whitespace_regexp (current_thread->m_whitespace_regexp) | 153 | #define whitespace_regexp (current_thread->m_whitespace_regexp) |
| 144 | 154 | ||
| 155 | /* The OS identifier for this thread. */ | ||
| 156 | sys_thread_t thread_id; | ||
| 157 | |||
| 158 | /* The condition variable for this thread. This is associated with | ||
| 159 | the global lock. This thread broadcasts to it when it exits. */ | ||
| 160 | sys_cond_t thread_condvar; | ||
| 161 | |||
| 162 | /* This thread might be waiting for some condition. If so, this | ||
| 163 | points to the condition. If the thread is interrupted, the | ||
| 164 | interrupter should broadcast to this condition. */ | ||
| 165 | sys_cond_t *wait_condvar; | ||
| 166 | |||
| 145 | /* Threads are kept on a linked list. */ | 167 | /* Threads are kept on a linked list. */ |
| 146 | struct thread_state *next_thread; | 168 | struct thread_state *next_thread; |
| 147 | }; | 169 | }; |
| @@ -149,10 +171,13 @@ struct thread_state | |||
| 149 | extern struct thread_state *current_thread; | 171 | extern struct thread_state *current_thread; |
| 150 | 172 | ||
| 151 | extern sys_mutex_t global_lock; | 173 | extern sys_mutex_t global_lock; |
| 174 | extern void post_acquire_global_lock (struct thread_state *); | ||
| 152 | 175 | ||
| 153 | extern void unmark_threads (void); | 176 | extern void unmark_threads (void); |
| 177 | extern void finalize_one_thread (struct thread_state *state); | ||
| 154 | 178 | ||
| 155 | extern void init_threads_once (void); | 179 | extern void init_threads_once (void); |
| 156 | extern void init_threads (void); | 180 | extern void init_threads (void); |
| 181 | extern void syms_of_threads (void); | ||
| 157 | 182 | ||
| 158 | #endif /* THREAD_H */ | 183 | #endif /* THREAD_H */ |