30 lines
784 B
C
30 lines
784 B
C
#ifdef STANDALONE
|
|
|
|
#ifndef THREADS_H
|
|
#define THREADS_H
|
|
|
|
#include "pebblisp.h"
|
|
|
|
Object clonePromise(Object src);
|
|
|
|
void cleanPromise(struct Promise* promise);
|
|
|
|
int isDone(struct Promise* promise);
|
|
|
|
int isPromise(Object src);
|
|
|
|
fn(async, "async",
|
|
"Run the given lambda on a separate thread, returning a promise.",
|
|
"(def sleepy (fn () ((sys \"sleep 0.01\") \"Hiya\"))) (def x (async sleepy)) x", "<PENDING>",
|
|
"(def sleepy (fn () ((sys \"sleep 0.01\") \"Hiya\"))) (def x (async sleepy)) (await x)", "Hiya",
|
|
);
|
|
|
|
tfn(await, "await",
|
|
({ expect(isPromise), anyType }),
|
|
"Waits for a promise to resolve before proceeding.",
|
|
"(def sleepy (fn () ((sys \"sleep 0.01\") \"Hiya\"))) (def x (async sleepy)) (await x)", "Hiya",
|
|
);
|
|
|
|
#endif // PEBBLISP_THREADS_H
|
|
|
|
#endif // STANDALONE
|