#include <ecl/ecl.h>
+thread_desc *
+make_thread_desc (cl_object thread) {
+ thread_desc *desc;
+
+ desc = (thread_desc *)malloc(sizeof(thread_desc));
+ desc->thread = thread;
+ desc->status = ECL_THREAD_SUSPENDED;
+ desc->base = NULL;
+ /* desc->env = ??; */
+ desc->slice = 0;
+ desc->input = NULL;
+ desc->lpd = NULL;
+ desc->next = NULL;
+}
+
cl_object
si_make_thread (cl_object fun) {
cl_object x;
+ if (cl_functionp(fun) == ECL_NIL)
+ FEwrong_type_argument(@'function', fun);
+
x = ecl_alloc_object(t_thread);
+ x->thread.entry = fun;
x->thread.cont = ECL_NIL;
+ x->thread.data = make_thread_desc(x);
return x;
}
+/* -*- mode: c; c-basic-offset: 8 -*- */
/*
lwp.h -- Light weight processes.
*/
extern "C" {
#endif
- /* XXX: put lwp structures here */
+typedef struct lpd {
+ /* this is basically env (right?) – compare sources */
+} lpd;
+
+enum {
+ ECL_THREAD_RUNNING = 0,
+ ECL_THREAD_SUSPENDED,
+ ECL_THREAD_STOPPED,
+ ECL_THREAD_DEAD,
+ ECL_THREAD_WAITING,
+ ECL_THREAD_DELAYED
+};
+
+typedef struct thread_desc {
+ cl_object thread; /* point back to its thread */
+ cl_index status; /* RUNNING or STOPPED or DEAD */
+ int *base; /* Stack Base */
+ sigjmp_buf env; /* Stack Environment */
+ int slice; /* time out */
+ FILE *input; /* File pointer waiting input on */
+ lpd *lpd; /* lisp process descriptor */
+ struct thread_desc *next;
+} thread_desc;
#ifdef __cplusplus
}
};
#ifdef ECL_LWP
+
struct ecl_cont {
_ECL_HDR2(resumed, timed_out);
cl_object thread;
struct ecl_thread {
_ECL_HDR;
- cl_object cont; /* its continuation */
+ cl_object entry; /* entry point */
+ cl_object cont; /* its continuation */
+ struct thread_desc *data; /* actual thread */
};
#endif /* ECL_LWP */