pebblisp/src/threads.h

30 lines
784 B
C
Raw Normal View History

#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",
2022-04-06 00:05:30 -04:00
"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