Functions for working with fetch promises.
More...
Functions for working with fetch promises.
◆ fetch_promise_await()
bool fetch_promise_await |
( |
fetch_promise_t * | promise, |
|
|
uint32_t | timeout_ms ) |
Wait for a promise to complete (BLOCKING)
This function blocks the calling thread and drives the event loop internally until the promise completes or times out.
- Parameters
-
promise | The promise to wait for |
timeout_ms | Maximum time to wait in milliseconds (0 for infinite) |
- Returns
- true if promise completed within timeout, false if timed out
- Warning
- This function BLOCKS the calling thread
- Note
- Event Loop: Drives the event loop internally while waiting
printf("Request completed successfully\n");
} else {
printf("Request failed\n");
}
} else {
printf("Request timed out\n");
}
fetch_promise_t * fetch_async(const char *url, fetch_init_t *init)
Make an asynchronous HTTP request (NON-BLOCKING)
Definition fetch.c:7764
void fetch_promise_free(fetch_promise_t *promise)
Free a promise object.
Definition fetch.c:8401
bool fetch_promise_fulfilled(const fetch_promise_t *promise)
Check if promise was fulfilled successfully.
Definition fetch.c:8020
bool fetch_promise_await(fetch_promise_t *promise, uint32_t timeout_ms)
Wait for a promise to complete (BLOCKING)
Definition fetch.c:7907
Promise for asynchronous fetch operations.
Definition fetch.h:563
◆ fetch_promise_cancel()
bool fetch_promise_cancel |
( |
fetch_promise_t * | promise, |
|
|
const char * | reason ) |
Cancel a pending promise.
- Parameters
-
promise | The promise to cancel |
reason | Optional reason for cancellation |
- Returns
- true if promise was cancelled, false if already completed
printf("Request was cancelled\n");
}
bool fetch_promise_cancel(fetch_promise_t *promise, const char *reason)
Cancel a pending promise.
Definition fetch.c:7943
◆ fetch_promise_cancelled()
Check if a promise was cancelled.
- Parameters
-
promise | The promise to check |
- Returns
- true if promise was cancelled
◆ fetch_promise_poll()
Check if a promise has completed (NON-BLOCKING)
- Parameters
-
promise | The promise to check |
- Returns
- true if promise is completed (fulfilled or rejected), false if still pending
- Note
- This function does NOT block and does NOT drive the event loop
-
You must call fetch_event_loop_process() separately to make progress
handle_other_tasks();
}
int fetch_event_loop_process(uint32_t timeout_ms)
Process events in the event loop (NON-BLOCKING with timeout)
Definition fetch.c:7339
bool fetch_promise_poll(fetch_promise_t *promise)
Check if a promise has completed (NON-BLOCKING)
Definition fetch.c:7900