X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fthread.h;h=b8b99d3c07fd29b8c89b618eaa420a47e41976af;hb=7be8d1462a207bda809cd7553c5d76c6ebc4dda2;hp=249d2260923695548df42bb85043ff6db72ca75b;hpb=f5bb745fdcc44fb8781c188ee8a909efbca79f7b;p=sbcl.git diff --git a/src/runtime/thread.h b/src/runtime/thread.h index 249d226..b8b99d3 100644 --- a/src/runtime/thread.h +++ b/src/runtime/thread.h @@ -10,50 +10,22 @@ #include "os.h" #ifdef LISP_FEATURE_GENCGC #include "gencgc-alloc-region.h" -#else -struct alloc_region { }; #endif #include "genesis/symbol.h" #include "genesis/static-symbols.h" + #include "genesis/thread.h" #include "genesis/fdefn.h" #include "interrupt.h" -#define STATE_RUNNING (make_fixnum(1)) -#define STATE_SUSPENDED (make_fixnum(2)) -#define STATE_DEAD (make_fixnum(3)) +#define STATE_RUNNING MAKE_FIXNUM(1) +#define STATE_STOPPED MAKE_FIXNUM(2) +#define STATE_DEAD MAKE_FIXNUM(3) #ifdef LISP_FEATURE_SB_THREAD - -/* Only access thread state with blockables blocked. */ -static inline lispobj -thread_state(struct thread *thread) -{ - lispobj state; - pthread_mutex_lock(thread->state_lock); - state = thread->state; - pthread_mutex_unlock(thread->state_lock); - return state; -} - -static inline void -set_thread_state(struct thread *thread, lispobj state) -{ - pthread_mutex_lock(thread->state_lock); - thread->state = state; - pthread_cond_broadcast(thread->state_cond); - pthread_mutex_unlock(thread->state_lock); -} - -static inline void -wait_for_thread_state_change(struct thread *thread, lispobj state) -{ - pthread_mutex_lock(thread->state_lock); - while (thread->state == state) - pthread_cond_wait(thread->state_cond, thread->state_lock); - pthread_mutex_unlock(thread->state_lock); -} - +lispobj thread_state(struct thread *thread); +void set_thread_state(struct thread *thread, lispobj state); +void wait_for_thread_state_change(struct thread *thread, lispobj state); extern pthread_key_t lisp_thread; #endif