* threads.h (scm_single_thread_p, scm_yield,
scm_call_with_new_thread, scm_join_thread, scm_make_mutex,
scm_lock_mutex, scm_unlock_mutex, scm_make_condition_variable,
scm_wait_condition_variable, scm_signal_condition_variable): Add
prototypes for these Scheme-visible functions.
* coop-defs.h (coop_next_runnable_thread,
coop_wait_for_runnable_thread_now, coop_wait_for_runnable_thread):
Prototypes for these here, even though they're from iselect.c.
(coop_condition_variable_wait, coop_join): Add prototypes.
* coop-threads.c (scm_threads_free_thread, scm_threads_free_mutex,
scm_threads_free_condvar): Make these smob functions static.
* coop-threads.h (coop_init): Give this a real prototype.
* coop.c: #include <unistd.h>, if we have it, for `usleep' and `sleep'.
(coop_next_runnable_thread): No need to provide prototype; it's in
coop-defs.h.
scheme_handler_bootstrip, scheme_launch_thread, c_launch_data,
c_body_bootstrip, c_handler_bootstrip, c_launch_thread): Add an
extra layer of functions around the body and handler of a thread.
This extra layer makes sure that the handler is called in the
dynamic context of the surround (= empty dynwind list), but under
the *dynamic root* of the body. We can not use the dynamic root
of the surround since that root belongs to another thread => stack
is not handled correctly. It may seem ugly to use this extra
layer, but the extra cost in terms of execution time is really
negligible compared to the total amount of time required to create
a thread, and it would reduce maintainability to duplicate the
crucial and complicated steps performed by cwdr.
* coop-threads.c (scm_wait_condition_variable): Use
coop_condition_variable_wait_mutex.
coop_condition_variable_init, coop_condition_variable_wait,
coop_condition_variable_signal): Changed return type from `void'
to `int'. This is to adhere closer to the pthreads interface.
This, in turn, is part of an attempt to provide C versions of the
mutex and condition variable primitives which can be part of a
frontend to COOP or pthreads.
* coop.c (coop_mutex_destroy, coop_condition_variable_wait_mutex,
coop_condition_variable_destroy): New functions.
* coop-threads.c (scm_wait_condition_variable): Use
coop_condition_variable_wait_mutex.
* coop-threads.h, coop-defs.h (coop_q_t, coop_m, coop_c):
Definitions moved to coop-defs.h.
* coop-defs.h (scm_mutex_init, scm_mutex_lock, scm_mutex_unlock,
scm_mutex_destroy, scm_cond_init, scm_cond_wait, scm_cond_signal,
scm_cond_destroy): New C interface to mutecis and cond vars.
(scm_call_with_new_thread): Bugfix: SCM_WNA should go as third
argument to SCM_ASSERT. Furthermore, the name of the function
should be passed as first argument when signalling
SCM_WNA. (Thanks to Thomas Morgan)