* threads.c (do_thread_exit, scm_cancel_thread,
[bpt/guile.git] / libguile / threads.h
index 89a7010..b19fbe3 100644 (file)
@@ -3,7 +3,7 @@
 #ifndef SCM_THREADS_H
 #define SCM_THREADS_H
 
-/* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 \f
@@ -49,9 +49,14 @@ typedef struct scm_i_thread {
 
   SCM handle;
   scm_i_pthread_t pthread;
-  
+
+  SCM cleanup_handler;
   SCM join_queue;
+
+  scm_i_pthread_mutex_t admin_mutex;
+
   SCM result;
+  int canceled;
   int exited;
 
   SCM sleep_object;
@@ -123,12 +128,9 @@ typedef struct scm_i_thread {
 SCM_API SCM scm_spawn_thread (scm_t_catch_body body, void *body_data,
                              scm_t_catch_handler handler, void *handler_data);
 
-typedef void *scm_t_guile_ticket;
-SCM_API void scm_enter_guile (scm_t_guile_ticket ticket);
-SCM_API scm_t_guile_ticket scm_leave_guile (void);
 SCM_API void *scm_without_guile (void *(*func)(void *), void *data);
-
 SCM_API void *scm_with_guile (void *(*func)(void *), void *data);
+
 SCM_API void *scm_i_with_guile_and_parent (void *(*func)(void *), void *data,
                                           SCM parent);
 
@@ -156,12 +158,15 @@ do { \
 
 SCM_API SCM scm_call_with_new_thread (SCM thunk, SCM handler);
 SCM_API SCM scm_yield (void);
+SCM_API SCM scm_cancel_thread (SCM t);
+SCM_API SCM scm_set_thread_cleanup_x (SCM thread, SCM proc);
+SCM_API SCM scm_thread_cleanup (SCM thread);
 SCM_API SCM scm_join_thread (SCM t);
 
 SCM_API SCM scm_make_mutex (void);
 SCM_API SCM scm_make_recursive_mutex (void);
 SCM_API SCM scm_lock_mutex (SCM m);
-SCM_API void scm_frame_lock_mutex (SCM mutex);
+SCM_API void scm_dynwind_lock_mutex (SCM mutex);
 SCM_API SCM scm_try_mutex (SCM m);
 SCM_API SCM scm_unlock_mutex (SCM m);
 
@@ -178,7 +183,7 @@ SCM_API SCM scm_all_threads (void);
 SCM_API int scm_c_thread_exited_p (SCM thread);
 SCM_API SCM scm_thread_exited_p (SCM thread);
 
-SCM_API void scm_frame_critical_section (SCM mutex);
+SCM_API void scm_dynwind_critical_section (SCM mutex);
 
 #define SCM_I_CURRENT_THREAD \
   ((scm_i_thread *) scm_i_pthread_getspecific (scm_i_thread_key))
@@ -198,7 +203,7 @@ SCM_API scm_i_pthread_mutex_t scm_i_misc_mutex;
 
 #if SCM_USE_PTHREAD_THREADS
 SCM_API int scm_pthread_mutex_lock (pthread_mutex_t *mutex);
-SCM_API void scm_frame_pthread_mutex_lock (pthread_mutex_t *mutex);
+SCM_API void scm_dynwind_pthread_mutex_lock (pthread_mutex_t *mutex);
 SCM_API int scm_pthread_cond_wait (pthread_cond_t *cond,
                                   pthread_mutex_t *mutex);
 SCM_API int scm_pthread_cond_timedwait (pthread_cond_t *cond,