LLAM v3.0.1

Blocking work

Edit pageReport a problemLast modified: 04 November 2026

Use LLAM blocking helpers when a managed task needs to call code that can block an OS thread.

On this page

Blocking callback

Focused snippet. Hand a blocking call to a helper thread and read its result:

C
#include <llam/runtime.h>

typedef struct work_result {
    int value;
} work_result_t;

static void *slow_call(void *arg) {
    work_result_t *result = arg;

    result->value = 42;
    return result;
}

static void task(void *arg) {
    work_result_t result = {0};
    void *out = NULL;

    (void)arg;

    if (llam_call_blocking_result(slow_call, &result, &out) == 0) {
        consume_result(((work_result_t *)out)->value);
    }
}

Prefer llam_call_blocking_result() for FFI and bindings because it separates LLAM submission errors from a callback that legitimately returns NULL.

Manual blocking region

Focused snippet. Use a manual region when an external API must run on the current OS thread:

C
if (llam_enter_blocking() == 0) {
    call_external_library();
    llam_leave_blocking();
}

The runtime compensates so the shard can keep scheduling other tasks while the current worker is pinned in foreign code.

DNS and filesystem wrappers

Focused snippet. Prefer LLAM wrappers for common blocking syscalls:

C
struct addrinfo *result = NULL;
int gai_error = 0;

if (llam_getaddrinfo_result("example.com",
                            "443",
                            NULL,
                            &result,
                            &gai_error) == 0) {
    llam_freeaddrinfo_result(result);
}

Filesystem open/stat wrappers follow the same principle and route through the blocking path from managed tasks.

↑↓ Navigate↵ Openesc CloseSearching the 3.0.1 docs