3 |
#ifndef SCM_THREADS_H |
#ifndef SCM_THREADS_H |
4 |
#define SCM_THREADS_H |
#define SCM_THREADS_H |
5 |
|
|
6 |
/* Copyright (C) 1996,1997,1998,2000,2001, 2002 Free Software Foundation, Inc. |
/* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003 Free Software Foundation, Inc. |
7 |
* |
* |
8 |
* This program is free software; you can redistribute it and/or modify |
* This program is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
83 |
SCM_ASSERT_TYPE (SCM_CONDVARP (a) || SCM_FAIR_CONDVAR_P (a), \ |
SCM_ASSERT_TYPE (SCM_CONDVARP (a) || SCM_FAIR_CONDVAR_P (a), \ |
84 |
a, pos, FUNC_NAME, "condition variable"); |
a, pos, FUNC_NAME, "condition variable"); |
85 |
|
|
|
#define SCM_VALIDATE_FUTURE(pos, obj) \ |
|
|
SCM_ASSERT_TYPE (SCM_TYP16_PREDICATE (scm_tc16_future, obj), \ |
|
|
obj, pos, FUNC_NAME, "future"); |
|
|
#define SCM_F_FUTURE_COMPUTED (1L << 16) |
|
|
#define SCM_FUTURE_COMPUTED_P(future) \ |
|
|
(SCM_F_FUTURE_COMPUTED & SCM_CELL_WORD_0 (future)) |
|
|
#define SCM_SET_FUTURE_COMPUTED(future) \ |
|
|
SCM_SET_CELL_WORD_0 (future, scm_tc16_future | SCM_F_FUTURE_COMPUTED) |
|
|
#define SCM_FUTURE_MUTEX(future) \ |
|
|
((scm_t_rec_mutex *) SCM_CELL_WORD_2 (future)) |
|
|
#define SCM_FUTURE_DATA SCM_CELL_OBJECT_1 |
|
|
#define SCM_SET_FUTURE_DATA SCM_SET_CELL_OBJECT_1 |
|
|
SCM_API scm_t_bits scm_tc16_future; |
|
|
|
|
86 |
SCM_API void scm_threads_mark_stacks (void); |
SCM_API void scm_threads_mark_stacks (void); |
87 |
SCM_API void scm_init_threads (SCM_STACKITEM *); |
SCM_API void scm_init_threads (SCM_STACKITEM *); |
88 |
SCM_API void scm_init_thread_procs (void); |
SCM_API void scm_init_thread_procs (void); |
185 |
/* End of low-level C API */ |
/* End of low-level C API */ |
186 |
/*----------------------------------------------------------------------*/ |
/*----------------------------------------------------------------------*/ |
187 |
|
|
|
extern SCM *scm_loc_sys_thread_handler; |
|
|
|
|
188 |
typedef struct scm_thread scm_thread; |
typedef struct scm_thread scm_thread; |
189 |
|
|
190 |
SCM_API void scm_i_enter_guile (scm_thread *t); |
SCM_API void scm_i_enter_guile (scm_thread *t); |
219 |
scm_i_thread_sleep_for_gc (); \ |
scm_i_thread_sleep_for_gc (); \ |
220 |
} while (0) |
} while (0) |
221 |
|
|
222 |
|
SCM scm_i_create_thread (scm_t_catch_body body, void *body_data, |
223 |
|
scm_t_catch_handler handler, void *handler_data, |
224 |
|
SCM protects); |
225 |
|
|
226 |
/* The C versions of the Scheme-visible thread functions. */ |
/* The C versions of the Scheme-visible thread functions. */ |
227 |
SCM_API SCM scm_call_with_new_thread (SCM thunk, SCM handler); |
SCM_API SCM scm_call_with_new_thread (SCM thunk, SCM handler); |
228 |
SCM_API SCM scm_yield (void); |
SCM_API SCM scm_yield (void); |
229 |
SCM_API SCM scm_join_thread (SCM t); |
SCM_API SCM scm_join_thread (SCM t); |
|
SCM_API SCM scm_i_make_future (SCM thunk); |
|
|
SCM_API SCM scm_future_ref (SCM future); |
|
230 |
SCM_API SCM scm_make_mutex (void); |
SCM_API SCM scm_make_mutex (void); |
231 |
SCM_API SCM scm_make_fair_mutex (void); |
SCM_API SCM scm_make_fair_mutex (void); |
232 |
SCM_API SCM scm_lock_mutex (SCM m); |
SCM_API SCM scm_lock_mutex (SCM m); |
248 |
|
|
249 |
SCM_API scm_root_state *scm_i_thread_root (SCM thread); |
SCM_API scm_root_state *scm_i_thread_root (SCM thread); |
250 |
|
|
251 |
|
#ifdef USE_PTHREAD_THREADS |
252 |
|
#include "libguile/pthread-threads.h" |
253 |
|
#else |
254 |
|
#include "libguile/null-threads.h" |
255 |
|
#endif |
256 |
|
|
257 |
#define SCM_CURRENT_THREAD \ |
#define SCM_CURRENT_THREAD \ |
258 |
((scm_thread *) scm_i_plugin_getspecific (scm_i_thread_key)) |
((scm_thread *) scm_i_plugin_getspecific (scm_i_thread_key)) |
259 |
extern scm_t_key scm_i_thread_key; |
extern scm_t_key scm_i_thread_key; |
275 |
}; |
}; |
276 |
#endif |
#endif |
277 |
|
|
|
#ifdef USE_PTHREAD_THREADS |
|
|
#include "libguile/pthread-threads.h" |
|
|
#else |
|
|
#include "libguile/null-threads.h" |
|
|
#endif |
|
|
|
|
278 |
#endif /* SCM_THREADS_H */ |
#endif /* SCM_THREADS_H */ |
279 |
|
|
280 |
/* |
/* |