X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fthread.h;h=fcc51b0744d415bbc11c93c88bdbdd52f9c0e825;hb=f7faed97898dd0e94a18b0d1fca03aaa0fe24ab0;hp=e62cb2ba1dce34ae97eb175d11d9c31234a33572;hpb=d67355bbb5c570cac6fe866113d79ce9de9b51a7;p=sbcl.git diff --git a/src/runtime/thread.h b/src/runtime/thread.h index e62cb2b..fcc51b0 100644 --- a/src/runtime/thread.h +++ b/src/runtime/thread.h @@ -15,54 +15,19 @@ 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; - sigset_t old; - block_blockable_signals(0, &old); - pthread_mutex_lock(thread->state_lock); - state = thread->state; - pthread_mutex_unlock(thread->state_lock); - thread_sigmask(SIG_SETMASK,&old,0); - return state; -} - -static inline void -set_thread_state(struct thread *thread, lispobj state) -{ - sigset_t old; - block_blockable_signals(0, &old); - pthread_mutex_lock(thread->state_lock); - thread->state = state; - pthread_cond_broadcast(thread->state_cond); - pthread_mutex_unlock(thread->state_lock); - thread_sigmask(SIG_SETMASK,&old,0); -} - -static inline void -wait_for_thread_state_change(struct thread *thread, lispobj state) -{ - sigset_t old; - block_blockable_signals(0, &old); - 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); - thread_sigmask(SIG_SETMASK,&old,0); -} - +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