Plumbing for promise integration.
This commit is contained in:
19
clients/c/promise.h
Normal file
19
clients/c/promise.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef _PROMISE_H
|
||||
#define _PROMISE_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct promise promise;
|
||||
|
||||
// (passthrough, result)
|
||||
typedef void (*promise_callback)(void *, void *);
|
||||
|
||||
promise *promise_create(bool will_wait, promise_callback on_success, promise_callback on_failure, void *passthrough);
|
||||
bool promise_wait(promise *promise_obj, void **result);
|
||||
|
||||
void promise_complete(promise *promise_obj, void *result, bool success);
|
||||
// Shortcuts for promise_complete()
|
||||
void promise_succeed(promise *promise_obj, void *result);
|
||||
void promise_fail(promise *promise_obj, void *result);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user