-
-
Notifications
You must be signed in to change notification settings - Fork 183
/
Copy pathreact.h
29 lines (21 loc) · 898 Bytes
/
react.h
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
#ifndef REACT_H
#define REACT_H
struct reactor;
struct cell;
typedef int (*compute1)(int);
typedef int (*compute2)(int, int);
struct reactor *create_reactor(void);
// destroy_reactor should free all cells created under that reactor.
void destroy_reactor(struct reactor *);
struct cell *create_input_cell(struct reactor *, int initial_value);
struct cell *create_compute1_cell(struct reactor *, struct cell *, compute1);
struct cell *create_compute2_cell(struct reactor *, struct cell *,
struct cell *, compute2);
int get_cell_value(struct cell *);
void set_cell_value(struct cell *, int new_value);
typedef void (*callback)(void *, int);
typedef int callback_id;
// The callback should be called with the same void * given in add_callback.
callback_id add_callback(struct cell *, void *, callback);
void remove_callback(struct cell *, callback_id);
#endif