Beginnings of a mutex type

This commit is contained in:
Justin Ethier 2015-12-30 21:59:37 -05:00
parent c7dd60bf06
commit c0ac60ba87
2 changed files with 9 additions and 0 deletions

View file

@ -15,6 +15,9 @@ TODO:
- add mutex type, and associated functions from SRFI-18
when allocating a mutex, probably should do it on thread since by definition these are
shared among multiple threads
- may be able to free mutex using mutex_destroy from within gc_sweep.
unfortunately it requires type checking each object before free, which is not ideal
- start making core stuff thread safe. for example, test.scm sometimes
crashes, I think printing out result from (read)
- assume I/O and eval both have threading issues

View file

@ -206,6 +206,7 @@ typedef long tag_type;
#define cvar_tag 16
#define vector_tag 17
#define macro_tag 18
#define mutex_tag 19
#define nil NULL
#define eq(x,y) (x == y)
@ -238,6 +239,11 @@ typedef struct {gc_header_type hdr; tag_type tag; object *pvar;} cvar_type;
typedef cvar_type *cvar;
#define make_cvar(n,v) cvar_type n; n.hdr.mark = gc_color_red; n.hdr.grayed = 0; n.tag = cvar_tag; n.pvar = v;
// TODO: mutex type
// thinking about maybe using cvar_type with a mutex tag
// add an alloc_mutex macro/function, because these will only go on the heap
/* Define boolean type. */
typedef struct {gc_header_type hdr; const tag_type tag; const char *pname;} boolean_type;
typedef boolean_type *boolean;