CIR Playground
Load example...
CIR on GitHub
Input
Run
// Async/await in CIR // First define the types/decls we must provide to the library: typedef unsigned promise_id; // Create a new unresolved promise promise_id promise_new(void); // Resolve promise void promise_resolve(promise_id); // Register promise completion callback void promise_then(promise_id, void (*cb)(void *), void *); // Now include the library #include <cirasync.h> // Other stuff we use but not strictly needed by cirasync // Returns a new promise that resolves after ms promise_id wait_ms(int ms); // Runs the event loop forever void engine_run(void); static promise_id f(int ms) { promise_id p = wait_ms(ms); @await(p); puts("wait1 done"); p = wait_ms(ms); @await(p); puts("wait2 done"); } @asyncTransform(f); int main(void) { f(1000); f(2000); engine_run(); return 0; }
stdout
stderr
Load Example...
×
00 - Compile-time fibonacci
01 - Inline Repeat
02 - Compile-time strtok
03 - Does a code call a function
04 - C Preprocessor identifiers may be accidentally shadowed
05 - CIR identifiers won't be accidentally shadowed
06 - C Preprocessor accidental capture of symbols
07 - CIR won't accidentally capture symbols
08 - bf-to-C (low level ver)
09 - bf-to-C (with quote-antiquote)
10 - async-await
11 - Embed an external file
12 - zlib