Adding thread application stubs

This commit is contained in:
Justin Ethier 2015-12-15 22:58:15 -05:00
parent 74b818ec2f
commit dfed77639a
3 changed files with 14 additions and 3 deletions

5
gc.c
View file

@ -70,7 +70,7 @@ void gc_initialize()
}
// Add data for a new mutator
void gc_add_mutator(gc_thread_data *thd)
int gc_add_mutator(gc_thread_data *thd)
{
// TODO: need to sync access to these static variables. both here and
// elsewhere in the module!!
@ -78,12 +78,13 @@ void gc_add_mutator(gc_thread_data *thd)
for (i = 0; i < Cyc_num_mutators; i++) {
if (!Cyc_mutators[i]) {
Cyc_mutators[i] = thd;
return;
return i;
}
}
// TODO: unable to create any more mutators. what to do???
fprintf(stderr, "Unable to create a new thread, exiting\n");
exit(1);
return -1;
}
gc_heap *gc_heap_create(size_t size, size_t max_size, size_t chunk_size)

View file

@ -159,7 +159,7 @@ void vpbuffer_free(void **buf);
/* GC prototypes */
void gc_initialize();
void gc_add_mutator(gc_thread_data *thd);
int gc_add_mutator(gc_thread_data *thd);
gc_heap *gc_heap_create(size_t size, size_t max_size, size_t chunk_size);
int gc_grow_heap(gc_heap *h, size_t size, size_t chunk_size);
char *gc_copy_obj(object hp, char *obj, gc_thread_data *thd);

View file

@ -1,5 +1,8 @@
(define-library (scheme base)
(export
;; Thread functions. these are not standard, and may be relocated
make-thread
;; END threads
; TODO: need filter for the next two. also, they really belong in SRFI-1, not here
;delete
;delete-duplicates
@ -95,6 +98,13 @@
quasiquote
)
(begin
;; Threading
(define (make-thread thunk . name)
(let ((name-str (if (pair? name)
(car name)
"")))
(list 'cyc-thread-obj thunk name-str)))
;; Features implemented by this Scheme
(define (features) '(cyclone r7rs exact-closed))