-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuture.h
More file actions
35 lines (24 loc) · 673 Bytes
/
future.h
File metadata and controls
35 lines (24 loc) · 673 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef FUTURE_H
#define FUTURE_H
#include "threadpool.h"
#include<pthread.h>
typedef struct callable {
void *(*function)(void *, size_t, size_t *);
void *arg;
size_t argsz;
} callable_t;
typedef struct future future_t;
typedef struct future {
pthread_cond_t await;
pthread_mutex_t lock;
void* solution;
bool isMapped;
future_t* mappedFut;
callable_t mappedCall;
thread_pool_t* mappedPool;
} future_t;
int async(thread_pool_t *pool, future_t *future, callable_t callable);
int map(thread_pool_t *pool, future_t *future, future_t *from,
void *(*function)(void *, size_t, size_t *));
void *await(future_t *future);
#endif