forked from dstogov/fiber-ext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
php_fiber.h
66 lines (47 loc) · 1.59 KB
/
php_fiber.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* fiber extension for PHP (c) 2017 Haitao Lv <php@lvht.net> */
#ifndef PHP_FIBER_H
# define PHP_FIBER_H
extern zend_module_entry fiber_module_entry;
# define phpext_fiber_ptr &fiber_module_entry
# define PHP_FIBER_VERSION "0.1.0"
# if defined(ZTS) && defined(COMPILE_DL_FIBER)
ZEND_TSRMLS_CACHE_EXTERN()
# endif
typedef struct _zend_fiber zend_fiber;
struct _zend_fiber {
zend_object std;
zval closure;
/* The suspended execution context. */
zend_execute_data *root_execute_data;
zend_execute_data *execute_data;
/* The separate stack used by fiber */
zend_vm_stack stack;
size_t stack_size;
/* original fiber to yield from this */
zend_fiber *original_fiber;
zval *send_value;
zend_uchar status;
};
static const zend_uchar ZEND_FIBER_STATUS_INIT = 0;
static const zend_uchar ZEND_FIBER_STATUS_SUSPENDED = 1;
static const zend_uchar ZEND_FIBER_STATUS_RUNNING = 2;
static const zend_uchar ZEND_FIBER_STATUS_FINISHED = 3;
static const zend_uchar ZEND_FIBER_STATUS_DEAD = 4;
#define REGISTER_FIBER_CLASS_CONST_LONG(const_name, value) \
zend_declare_class_constant_long(zend_ce_fiber, const_name, sizeof(const_name)-1, (zend_long)value);
ZEND_BEGIN_MODULE_GLOBALS(fiber)
zend_fiber *current_fiber;
zend_fiber *next_fiber;
zend_long stack_size;
/* Suspended main execution context */
zend_execute_data *orig_execute_data;
zend_vm_stack orig_stack;
size_t orig_stack_page_size;
volatile zend_bool pending_interrupt;
ZEND_END_MODULE_GLOBALS(fiber)
#define FIBER_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(fiber, v)
#endif /* PHP_FIBER_H */
/*
* vim: sw=4 ts=4
* vim600: fdm=marker
*/