summaryrefslogtreecommitdiff
path: root/include/tinyff/thread/thread.h
blob: 252f04442a48020370e7f301bd07d5e8d353730f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifdef USE_THREAD

#ifndef TINYFF_THREAD_H
#define TINYFF_THREAD_H

#include <tinyff/common.h>
#include <tinyff/result.h>

typedef void (*ff_job_cb)(void *arg);

typedef struct {
    ff_job_cb callback;
    void *arg;
    ff_ctx *ctx;
} ff_thread_job;

void *ff_thread_wrapper(void *ptr);

// High level helper: allocate a job using ctx->allocator and schedule it.
// Returns FF_RESULT_OK on success, or an error ff_result on failure.
ff_result ff_thread_submit(ff_ctx *ctx, ff_job_cb callback, void *arg);

#endif
#endif