Work on moving to mailbox abstraction.

Should be more efficient in the common case.
This commit is contained in:
Calvin Rose
2019-12-07 12:14:16 -06:00
parent 0e690b4fa0
commit 73f5314141
2 changed files with 195 additions and 213 deletions
+3 -18
View File
@@ -944,26 +944,11 @@ struct JanetRNG {
/* Thread types */
#ifdef JANET_THREADS
#include <pthread.h>
typedef struct JanetThread JanetThread;
typedef struct JanetChannel JanetChannel;
typedef struct JanetThreadSelector JanetThreadSelector;
struct JanetThreadSelector {
pthread_mutex_t mutex;
pthread_cond_t cond;
JanetChannel *channel;
};
struct JanetChannel {
pthread_mutex_t lock;
JanetBuffer buf;
int refCount;
JanetThreadSelector *selector;
JanetTable *encode; /* only touched by writers */
JanetTable *decode; /* only touched by readers */
};
typedef struct JanetMailbox JanetMailbox;
struct JanetThread {
JanetChannel *rx;
JanetChannel *tx;
JanetMailbox *mailbox;
JanetTable *encode;
};
#endif