Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added missing files (beginning sparks implementation)

  • Loading branch information...
commit 01e42243f241d6a9f9ae98ee92a254bf40bb4360 1 parent cec565c
Edwin Brady authored
Showing with 46 additions and 0 deletions.
  1. +36 −0 evm/sparks.c
  2. +10 −0 evm/sparks.h
View
36 evm/sparks.c
@@ -0,0 +1,36 @@
+#include "sparks.h"
+
+void sparkThread(VAL thunk) {
+ spark* s = (spark*)(thunk->info);
+
+ pthread_mutex_lock(s->lock);
+ SETTY(thunk, RUNNING);
+ pthread_mutex_unlock(s->lock);
+
+ VAL ans = DO_EVAL(s->thunk, 1);
+
+ pthread_mutex_lock(s->lock);
+ UPDATE(thunk, ans);
+// pthread_cond_broadcast(s->cond);
+ pthread_mutex_unlock(s->lock);
+}
+
+VAL addSpark(VAL thunk) {
+ VAL c = EMALLOC(sizeof(Closure)+sizeof(spark));
+ spark* s = (spark*)(c+1);
+
+ pthread_mutex_t m;
+ pthread_mutex_init(&m, NULL);
+
+// pthread_cond_t cond;
+// pthread_cond_init(&cond, NULL);
+
+ s->thunk = thunk;
+ s->lock = &m;
+ s->cond = NULL; // &cond;
+
+ c->info = (void*)s;
+ SETTY(c, RUNNING);
+
+ return c;
+}
View
10 evm/sparks.h
@@ -0,0 +1,10 @@
+#ifndef _SPARKS_H
+#define _SPARKS_H
+
+#include "gc_header.h"
+#include "closure.h"
+
+VAL addSpark(VAL thunk);
+//void startWorker();
+
+#endif
Please sign in to comment.
Something went wrong with that request. Please try again.