-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker.h
42 lines (31 loc) · 1.14 KB
/
worker.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
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef _WORKER_H
#define _WORKER_H 1
#include "towntalk.h"
/*
Extension for multi-threaded subinterpreters.
*/
/* Reference-counted worker function. */
struct worker {
struct custom custom;
struct environment env;
struct variable *args, result, exception;
struct expression *parameters;
char locked, worker_locked;
struct array *strings;
void *thread, *mutex;
enum result ret;
};
int initialize_worker_extension( struct environment *env, char *message );
/* Add thread-safe custom statements and operators to the specified worker.
Returns 0 and assigns message on failure. */
int initialize_worker( struct worker *work, char *message );
/* Begin execution of the specified worker. Returns 0 on failure. */
int start_worker( struct worker *work );
/* Lock the specified worker mutex. Returns 0 on failure. */
int lock_worker( struct worker *work );
/* Unlock the specified worker mutex. Returns 0 on failure. */
int unlock_worker( struct worker *work );
/* Wait for the completion of the specified worker.
If cancel is non-zero, the worker should be interrupted. */
void await_worker( struct worker *work, int cancel );
#endif /* _WORKER_H */