guile/libguile/threads.h

167 lines
5.7 KiB
C
Raw Normal View History

/* classes: h_files */
#ifndef SCM_THREADS_H
#define SCM_THREADS_H
/* Copyright (C) 1996,1997,1998,2000,2001, 2002 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
1997-05-26 22:34:48 +00:00
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
1997-05-26 22:34:48 +00:00
* If you do not wish that, delete this exception notice. */
#include "libguile/__scm.h"
#include "libguile/procs.h"
#include "libguile/throw.h"
#include "libguile/root.h"
#include "libguile/iselect.h"
/* smob tags for the thread datatypes */
SCM_API scm_t_bits scm_tc16_thread;
SCM_API scm_t_bits scm_tc16_mutex;
SCM_API scm_t_bits scm_tc16_condvar;
2000-12-08 17:32:56 +00:00
#define SCM_THREADP(x) SCM_TYP16_PREDICATE (scm_tc16_thread, x)
#define SCM_THREAD_DATA(x) ((void *) SCM_CELL_WORD_1 (x))
#define SCM_MUTEXP(x) SCM_TYP16_PREDICATE (scm_tc16_mutex, x)
2000-12-08 17:32:56 +00:00
#define SCM_MUTEX_DATA(x) ((void *) SCM_CELL_WORD_1 (x))
2000-12-08 17:32:56 +00:00
#define SCM_CONDVARP(x) SCM_TYP16_PREDICATE (scm_tc16_condvar, x)
#define SCM_CONDVAR_DATA(x) ((void *) SCM_CELL_WORD_1 (x))
#define SCM_VALIDATE_THREAD(pos, a) \
SCM_MAKE_VALIDATE_MSG (pos, a, THREADP, "thread")
#define SCM_VALIDATE_MUTEX(pos, a) \
SCM_MAKE_VALIDATE_MSG (pos, a, MUTEXP, "mutex")
#define SCM_VALIDATE_CONDVAR(pos, a) \
SCM_MAKE_VALIDATE_MSG (pos, a, CONDVARP, "condition variable")
SCM_API void scm_threads_mark_stacks (void);
SCM_API void scm_init_threads (SCM_STACKITEM *);
* threads.h: Include "coop-pthreads.h" when requested. (scm_threads_make_mutex, scm_threads_lock_mutex, scm_threads_unlock_mutex, scm_threads_monitor): Removed, they were not implemented anyway. (scm_init_thread_procs, scm_try_mutex, scm_timed_condition_variable_wait, scm_broadcast_condition_variable, scm_c_thread_exited_p, scm_thread_exited_p): New prototypes. (struct timespec): Define if not already defined. (scm_t_mutex, scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_t_cond, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Declarations moved here and deprecated. * threads.c: Include <errno.h>. Include "coop-pthreads.c" when requested. (scm_thread_exited_p): New. (scm_try_mutex, scm_broadcast_condition_variable): Newly registered procedures. (scm_wait_condition_variable, scm_timed_wait_condition_variable): Use the latter as the procedure for "wait-condition-variable", thus offering a optional timeout parameter to Scheme. (scm_wait_condition_variable): Implement in terms of scm_timed_wait_condition_variable. (scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Implement in terms of scm_make_mutex, etc, and deprecate. (scm_init_threads): Do not create smobs, leave this to scm_threads_init. Do not include "threads.x" file. (scm_init_thread_procs): New, include "threads.x" here. * null-threads.h (scm_null_mutex, scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed. (scm_mutex_init, scm_mutex_lock, scm_mutex_unlock, scm_cond_init, scm_cond_wait, scm_cond_signal, scm_cond_broadcast, scm_cond_destory): Do not define, they are now deprecated and handled by threads.{h,c}. * null-threads.c (scm_null_mutex, scm_null_cond): Define here. (scm_threads_init): Create smobs here, using the appropriate sizes. (block): Removed, now unused. (scm_c_thread_exited_p): New. (scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed and updated users to do their task directly. (scm_try_mutex, timeval_subtract, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed. * coop-threads.c (scm_threads_init): Create smobs here, using the appropriate sizes. (scm_c_thread_exited_p, scm_try_mutex, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed.
2002-10-27 20:12:37 +00:00
SCM_API void scm_init_thread_procs (void);
SCM_API SCM scm_spawn_thread (scm_t_catch_body body, void *body_data,
scm_t_catch_handler handler, void *handler_data);
/* These are versions of the ordinary sleep and usleep functions
that play nicely with the thread system. */
SCM_API unsigned long scm_thread_sleep (unsigned long);
SCM_API unsigned long scm_thread_usleep (unsigned long);
/* Critical sections */
/* Since only one thread can be active anyway, we don't need to do
anything special around critical sections. In fact, that's the
reason we do only support cooperative threading: Guile's critical
regions have not been completely identified yet. (I think.) */
#define SCM_CRITICAL_SECTION_START
#define SCM_CRITICAL_SECTION_END
/* Switching */
SCM_API int scm_i_switch_counter;
#define SCM_I_THREAD_SWITCH_COUNT 50
#define SCM_THREAD_SWITCHING_CODE \
do { \
scm_i_switch_counter--; \
if (scm_i_switch_counter == 0) \
{ \
scm_i_switch_counter = SCM_I_THREAD_SWITCH_COUNT; \
scm_yield(); \
} \
} while (0)
/* The C versions of the Scheme-visible thread functions. */
SCM_API SCM scm_yield (void);
SCM_API SCM scm_call_with_new_thread (SCM thunk, SCM handler);
SCM_API SCM scm_join_thread (SCM t);
SCM_API SCM scm_make_mutex (void);
SCM_API SCM scm_lock_mutex (SCM m);
* threads.h: Include "coop-pthreads.h" when requested. (scm_threads_make_mutex, scm_threads_lock_mutex, scm_threads_unlock_mutex, scm_threads_monitor): Removed, they were not implemented anyway. (scm_init_thread_procs, scm_try_mutex, scm_timed_condition_variable_wait, scm_broadcast_condition_variable, scm_c_thread_exited_p, scm_thread_exited_p): New prototypes. (struct timespec): Define if not already defined. (scm_t_mutex, scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_t_cond, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Declarations moved here and deprecated. * threads.c: Include <errno.h>. Include "coop-pthreads.c" when requested. (scm_thread_exited_p): New. (scm_try_mutex, scm_broadcast_condition_variable): Newly registered procedures. (scm_wait_condition_variable, scm_timed_wait_condition_variable): Use the latter as the procedure for "wait-condition-variable", thus offering a optional timeout parameter to Scheme. (scm_wait_condition_variable): Implement in terms of scm_timed_wait_condition_variable. (scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Implement in terms of scm_make_mutex, etc, and deprecate. (scm_init_threads): Do not create smobs, leave this to scm_threads_init. Do not include "threads.x" file. (scm_init_thread_procs): New, include "threads.x" here. * null-threads.h (scm_null_mutex, scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed. (scm_mutex_init, scm_mutex_lock, scm_mutex_unlock, scm_cond_init, scm_cond_wait, scm_cond_signal, scm_cond_broadcast, scm_cond_destory): Do not define, they are now deprecated and handled by threads.{h,c}. * null-threads.c (scm_null_mutex, scm_null_cond): Define here. (scm_threads_init): Create smobs here, using the appropriate sizes. (block): Removed, now unused. (scm_c_thread_exited_p): New. (scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed and updated users to do their task directly. (scm_try_mutex, timeval_subtract, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed. * coop-threads.c (scm_threads_init): Create smobs here, using the appropriate sizes. (scm_c_thread_exited_p, scm_try_mutex, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed.
2002-10-27 20:12:37 +00:00
SCM_API SCM scm_try_mutex (SCM m);
SCM_API SCM scm_unlock_mutex (SCM m);
SCM_API SCM scm_make_condition_variable (void);
SCM_API SCM scm_wait_condition_variable (SCM cond, SCM mutex);
* threads.h: Include "coop-pthreads.h" when requested. (scm_threads_make_mutex, scm_threads_lock_mutex, scm_threads_unlock_mutex, scm_threads_monitor): Removed, they were not implemented anyway. (scm_init_thread_procs, scm_try_mutex, scm_timed_condition_variable_wait, scm_broadcast_condition_variable, scm_c_thread_exited_p, scm_thread_exited_p): New prototypes. (struct timespec): Define if not already defined. (scm_t_mutex, scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_t_cond, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Declarations moved here and deprecated. * threads.c: Include <errno.h>. Include "coop-pthreads.c" when requested. (scm_thread_exited_p): New. (scm_try_mutex, scm_broadcast_condition_variable): Newly registered procedures. (scm_wait_condition_variable, scm_timed_wait_condition_variable): Use the latter as the procedure for "wait-condition-variable", thus offering a optional timeout parameter to Scheme. (scm_wait_condition_variable): Implement in terms of scm_timed_wait_condition_variable. (scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Implement in terms of scm_make_mutex, etc, and deprecate. (scm_init_threads): Do not create smobs, leave this to scm_threads_init. Do not include "threads.x" file. (scm_init_thread_procs): New, include "threads.x" here. * null-threads.h (scm_null_mutex, scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed. (scm_mutex_init, scm_mutex_lock, scm_mutex_unlock, scm_cond_init, scm_cond_wait, scm_cond_signal, scm_cond_broadcast, scm_cond_destory): Do not define, they are now deprecated and handled by threads.{h,c}. * null-threads.c (scm_null_mutex, scm_null_cond): Define here. (scm_threads_init): Create smobs here, using the appropriate sizes. (block): Removed, now unused. (scm_c_thread_exited_p): New. (scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed and updated users to do their task directly. (scm_try_mutex, timeval_subtract, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed. * coop-threads.c (scm_threads_init): Create smobs here, using the appropriate sizes. (scm_c_thread_exited_p, scm_try_mutex, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed.
2002-10-27 20:12:37 +00:00
SCM_API SCM scm_timed_wait_condition_variable (SCM cond, SCM mutex,
SCM abstime);
SCM_API SCM scm_signal_condition_variable (SCM cond);
* threads.h: Include "coop-pthreads.h" when requested. (scm_threads_make_mutex, scm_threads_lock_mutex, scm_threads_unlock_mutex, scm_threads_monitor): Removed, they were not implemented anyway. (scm_init_thread_procs, scm_try_mutex, scm_timed_condition_variable_wait, scm_broadcast_condition_variable, scm_c_thread_exited_p, scm_thread_exited_p): New prototypes. (struct timespec): Define if not already defined. (scm_t_mutex, scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_t_cond, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Declarations moved here and deprecated. * threads.c: Include <errno.h>. Include "coop-pthreads.c" when requested. (scm_thread_exited_p): New. (scm_try_mutex, scm_broadcast_condition_variable): Newly registered procedures. (scm_wait_condition_variable, scm_timed_wait_condition_variable): Use the latter as the procedure for "wait-condition-variable", thus offering a optional timeout parameter to Scheme. (scm_wait_condition_variable): Implement in terms of scm_timed_wait_condition_variable. (scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Implement in terms of scm_make_mutex, etc, and deprecate. (scm_init_threads): Do not create smobs, leave this to scm_threads_init. Do not include "threads.x" file. (scm_init_thread_procs): New, include "threads.x" here. * null-threads.h (scm_null_mutex, scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed. (scm_mutex_init, scm_mutex_lock, scm_mutex_unlock, scm_cond_init, scm_cond_wait, scm_cond_signal, scm_cond_broadcast, scm_cond_destory): Do not define, they are now deprecated and handled by threads.{h,c}. * null-threads.c (scm_null_mutex, scm_null_cond): Define here. (scm_threads_init): Create smobs here, using the appropriate sizes. (block): Removed, now unused. (scm_c_thread_exited_p): New. (scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed and updated users to do their task directly. (scm_try_mutex, timeval_subtract, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed. * coop-threads.c (scm_threads_init): Create smobs here, using the appropriate sizes. (scm_c_thread_exited_p, scm_try_mutex, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed.
2002-10-27 20:12:37 +00:00
SCM_API SCM scm_broadcast_condition_variable (SCM cond);
SCM_API SCM scm_current_thread (void);
SCM_API SCM scm_all_threads (void);
* threads.h: Include "coop-pthreads.h" when requested. (scm_threads_make_mutex, scm_threads_lock_mutex, scm_threads_unlock_mutex, scm_threads_monitor): Removed, they were not implemented anyway. (scm_init_thread_procs, scm_try_mutex, scm_timed_condition_variable_wait, scm_broadcast_condition_variable, scm_c_thread_exited_p, scm_thread_exited_p): New prototypes. (struct timespec): Define if not already defined. (scm_t_mutex, scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_t_cond, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Declarations moved here and deprecated. * threads.c: Include <errno.h>. Include "coop-pthreads.c" when requested. (scm_thread_exited_p): New. (scm_try_mutex, scm_broadcast_condition_variable): Newly registered procedures. (scm_wait_condition_variable, scm_timed_wait_condition_variable): Use the latter as the procedure for "wait-condition-variable", thus offering a optional timeout parameter to Scheme. (scm_wait_condition_variable): Implement in terms of scm_timed_wait_condition_variable. (scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Implement in terms of scm_make_mutex, etc, and deprecate. (scm_init_threads): Do not create smobs, leave this to scm_threads_init. Do not include "threads.x" file. (scm_init_thread_procs): New, include "threads.x" here. * null-threads.h (scm_null_mutex, scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed. (scm_mutex_init, scm_mutex_lock, scm_mutex_unlock, scm_cond_init, scm_cond_wait, scm_cond_signal, scm_cond_broadcast, scm_cond_destory): Do not define, they are now deprecated and handled by threads.{h,c}. * null-threads.c (scm_null_mutex, scm_null_cond): Define here. (scm_threads_init): Create smobs here, using the appropriate sizes. (block): Removed, now unused. (scm_c_thread_exited_p): New. (scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed and updated users to do their task directly. (scm_try_mutex, timeval_subtract, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed. * coop-threads.c (scm_threads_init): Create smobs here, using the appropriate sizes. (scm_c_thread_exited_p, scm_try_mutex, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed.
2002-10-27 20:12:37 +00:00
SCM_API int scm_c_thread_exited_p (SCM thread);
SCM_API SCM scm_thread_exited_p (SCM thread);
SCM_API scm_root_state *scm_i_thread_root (SCM thread);
SCM_API void *scm_i_thread_data;
SCM_API void scm_i_set_thread_data (void *);
#define SCM_THREAD_LOCAL_DATA scm_i_thread_data
#define SCM_SET_THREAD_LOCAL_DATA(x) scm_i_set_thread_data(x)
* threads.h: Include "coop-pthreads.h" when requested. (scm_threads_make_mutex, scm_threads_lock_mutex, scm_threads_unlock_mutex, scm_threads_monitor): Removed, they were not implemented anyway. (scm_init_thread_procs, scm_try_mutex, scm_timed_condition_variable_wait, scm_broadcast_condition_variable, scm_c_thread_exited_p, scm_thread_exited_p): New prototypes. (struct timespec): Define if not already defined. (scm_t_mutex, scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_t_cond, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Declarations moved here and deprecated. * threads.c: Include <errno.h>. Include "coop-pthreads.c" when requested. (scm_thread_exited_p): New. (scm_try_mutex, scm_broadcast_condition_variable): Newly registered procedures. (scm_wait_condition_variable, scm_timed_wait_condition_variable): Use the latter as the procedure for "wait-condition-variable", thus offering a optional timeout parameter to Scheme. (scm_wait_condition_variable): Implement in terms of scm_timed_wait_condition_variable. (scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Implement in terms of scm_make_mutex, etc, and deprecate. (scm_init_threads): Do not create smobs, leave this to scm_threads_init. Do not include "threads.x" file. (scm_init_thread_procs): New, include "threads.x" here. * null-threads.h (scm_null_mutex, scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed. (scm_mutex_init, scm_mutex_lock, scm_mutex_unlock, scm_cond_init, scm_cond_wait, scm_cond_signal, scm_cond_broadcast, scm_cond_destory): Do not define, they are now deprecated and handled by threads.{h,c}. * null-threads.c (scm_null_mutex, scm_null_cond): Define here. (scm_threads_init): Create smobs here, using the appropriate sizes. (block): Removed, now unused. (scm_c_thread_exited_p): New. (scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed and updated users to do their task directly. (scm_try_mutex, timeval_subtract, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed. * coop-threads.c (scm_threads_init): Create smobs here, using the appropriate sizes. (scm_c_thread_exited_p, scm_try_mutex, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed.
2002-10-27 20:12:37 +00:00
#ifndef HAVE_STRUCT_TIMESPEC
/* POSIX.4 structure for a time value. This is like a `struct timeval' but
has nanoseconds instead of microseconds. */
struct timespec
{
long int tv_sec; /* Seconds. */
long int tv_nsec; /* Nanoseconds. */
};
#endif
#ifdef USE_COPT_THREADS
#include "libguile/pthread-threads.h"
* threads.h: Include "coop-pthreads.h" when requested. (scm_threads_make_mutex, scm_threads_lock_mutex, scm_threads_unlock_mutex, scm_threads_monitor): Removed, they were not implemented anyway. (scm_init_thread_procs, scm_try_mutex, scm_timed_condition_variable_wait, scm_broadcast_condition_variable, scm_c_thread_exited_p, scm_thread_exited_p): New prototypes. (struct timespec): Define if not already defined. (scm_t_mutex, scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_t_cond, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Declarations moved here and deprecated. * threads.c: Include <errno.h>. Include "coop-pthreads.c" when requested. (scm_thread_exited_p): New. (scm_try_mutex, scm_broadcast_condition_variable): Newly registered procedures. (scm_wait_condition_variable, scm_timed_wait_condition_variable): Use the latter as the procedure for "wait-condition-variable", thus offering a optional timeout parameter to Scheme. (scm_wait_condition_variable): Implement in terms of scm_timed_wait_condition_variable. (scm_mutex_init, scm_mutex_lock, scm_mutex_trylock, scm_mutex_unlock, scm_mutex_destroy, scm_cond_init, scm_cond_wait, scm_cond_timedwait, scm_cond_signal, scm_cond_broadcast, scm_cond_destroy): Implement in terms of scm_make_mutex, etc, and deprecate. (scm_init_threads): Do not create smobs, leave this to scm_threads_init. Do not include "threads.x" file. (scm_init_thread_procs): New, include "threads.x" here. * null-threads.h (scm_null_mutex, scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed. (scm_mutex_init, scm_mutex_lock, scm_mutex_unlock, scm_cond_init, scm_cond_wait, scm_cond_signal, scm_cond_broadcast, scm_cond_destory): Do not define, they are now deprecated and handled by threads.{h,c}. * null-threads.c (scm_null_mutex, scm_null_cond): Define here. (scm_threads_init): Create smobs here, using the appropriate sizes. (block): Removed, now unused. (scm_c_thread_exited_p): New. (scm_null_mutex_init, scm_null_mutex_lock, scm_null_mutex_unlock, scm_null_mutex_destroy, scm_null_condvar_init, scm_null_condvar_wait, scm_null_condvar_signal, scm_null_condvar_destroy): Removed and updated users to do their task directly. (scm_try_mutex, timeval_subtract, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed. * coop-threads.c (scm_threads_init): Create smobs here, using the appropriate sizes. (scm_c_thread_exited_p, scm_try_mutex, scm_timed_wait_condition_variable, scm_broadcast_condition_variable): New. (scm_wait_condition_variable): Removed.
2002-10-27 20:12:37 +00:00
#else
#include "libguile/null-threads.h"
#endif
#endif /* SCM_THREADS_H */
/*
Local Variables:
c-file-style: "gnu"
End:
*/