Go to the documentation of this file.
12 #include "../threadpool/threadpool.h"
18 void *(*function)(
void*, size_t,
size_t*);
58 void* (*
function)(
void*,
size_t,
size_t*));
66 #endif // __FUTURE_H__
int async(thread_pool_t *pool, future_t *future, callable_t callable)
Create a future variable that will store the result of callable.
Definition: future.c:50
static void fun_with_wait(void *arg, size_t size __attribute__((unused)))
Helper function for map.
Definition: future.c:38
Runnable function.
Definition: threadpool.h:20
void *(* function)(void *, size_t, size_t *)
f(arg, argsz, result_size);
Definition: future.h:18
sem_t finished
status of the future(pending/finished);
Definition: future.h:29
int map(thread_pool_t *pool, future_t *future, future_t *from, void *(*function)(void *, size_t, size_t *))
Create a future variable that will store the result of callable.
Definition: future.c:68
future_t * second
pointer to second future;
Definition: future.c:20
Thread-pool.
Definition: threadpool.h:46
void * arg
array of arguments;
Definition: future.h:19
Callable function.
Definition: future.h:17
struct pair_future pair_future_t
Pair of future variables.
void * await(future_t *future)
Wait for future to finish.
Definition: future.c:100
__attribute__((constructor))
Constructor of the exception handler.
Definition: threadpool.c:115
void * result
pointer to the result of the function;
Definition: future.h:30
void(* function)(void *, size_t)
f(arg, argsz);
Definition: threadpool.h:21
int map(thread_pool_t *pool, future_t *future, future_t *from, void *(*function)(void *, size_t, size_t *))
Create a future variable that will store the result of callable.
Definition: future.c:68
int async(thread_pool_t *pool, future_t *future, callable_t callable)
Create a future variable that will store the result of callable.
Definition: future.c:50
static void fun(void *arg, size_t size __attribute__((unused)))
Wrap callable function in runnable.
Definition: future.c:28
struct future future_t
Future that will get the value asynchronously (similar to C++ std::future).
void * await(future_t *future)
Wait for future to finish.
Definition: future.c:100
size_t argsz
number of arguments;
Definition: future.h:20
callable_t callable
callable function;
Definition: future.h:28
future_t * first
pointer to first future;
Definition: future.c:19
size_t argsz
number of arguments;
Definition: threadpool.h:23
Future that will get the value asynchronously (similar to C++ std::future).
Definition: future.h:27
void * arg
array of arguments;
Definition: threadpool.h:22
size_t result_size
size of the result;
Definition: future.h:31
Pair of future variables.
Definition: future.c:18
struct callable callable_t
Callable function.
int defer(struct thread_pool *pool, runnable_t runnable)
Add a new task to the pool.
Definition: threadpool.c:318