|
19 | 19 | #include "zend_fibers.h" |
20 | 20 | #include "zend_globals.h" |
21 | 21 |
|
22 | | -#define ZEND_ASYNC_API "TrueAsync API v0.4.0" |
| 22 | +#define ZEND_ASYNC_API "TrueAsync API v0.5.0" |
23 | 23 | #define ZEND_ASYNC_API_VERSION_MAJOR 0 |
24 | | -#define ZEND_ASYNC_API_VERSION_MINOR 4 |
| 24 | +#define ZEND_ASYNC_API_VERSION_MINOR 5 |
25 | 25 | #define ZEND_ASYNC_API_VERSION_PATCH 0 |
26 | 26 |
|
27 | 27 | #define ZEND_ASYNC_API_VERSION_NUMBER \ |
@@ -106,6 +106,7 @@ typedef enum |
106 | 106 |
|
107 | 107 | ZEND_ASYNC_CLASS_CHANNEL = 10, |
108 | 108 | ZEND_ASYNC_CLASS_FUTURE = 11, |
| 109 | + ZEND_ASYNC_CLASS_GROUP = 12, |
109 | 110 |
|
110 | 111 | ZEND_ASYNC_EXCEPTION_DEFAULT = 30, |
111 | 112 | ZEND_ASYNC_EXCEPTION_CANCELLATION = 31, |
@@ -134,6 +135,7 @@ typedef struct _zend_async_waker_s zend_async_waker_t; |
134 | 135 | typedef struct _zend_async_microtask_s zend_async_microtask_t; |
135 | 136 | typedef struct _zend_async_scope_s zend_async_scope_t; |
136 | 137 | typedef struct _zend_async_iterator_s zend_async_iterator_t; |
| 138 | +typedef struct _zend_async_group_s zend_async_group_t; |
137 | 139 | typedef struct _zend_fcall_s zend_fcall_t; |
138 | 140 | typedef void (*zend_coroutine_entry_t)(void); |
139 | 141 |
|
@@ -217,8 +219,13 @@ typedef zend_array* (*zend_async_get_coroutines_t)(void); |
217 | 219 | typedef void (*zend_async_add_microtask_t)(zend_async_microtask_t *microtask); |
218 | 220 | typedef zend_array* (*zend_async_get_awaiting_info_t)(zend_coroutine_t * coroutine); |
219 | 221 | typedef zend_class_entry* (*zend_async_get_class_ce_t)(zend_async_class type); |
220 | | -typedef zend_future_t* (*zend_async_future_create_t)(bool thread_safe, size_t extra_size); |
221 | | -typedef zend_async_channel_t* (*zend_async_channel_create_t)(size_t buffer_size, bool resizable, bool thread_safe, size_t extra_size); |
| 222 | +typedef zend_future_t* (*zend_async_new_future_t)(bool thread_safe, size_t extra_size); |
| 223 | +typedef zend_async_channel_t* (*zend_async_new_channel_t)(size_t buffer_size, bool resizable, bool thread_safe, size_t extra_size); |
| 224 | + |
| 225 | +typedef zend_async_group_t* (*zend_async_new_group_t)(size_t extra_size); |
| 226 | + |
| 227 | +typedef zend_object* (*zend_async_new_future_obj_t)(zend_future_t *future); |
| 228 | +typedef zend_object* (*zend_async_new_channel_obj_t)(zend_async_channel_t *channel); |
222 | 229 |
|
223 | 230 | typedef void (*zend_async_reactor_startup_t)(void); |
224 | 231 | typedef void (*zend_async_reactor_shutdown_t)(void); |
@@ -286,6 +293,8 @@ typedef int (* zend_async_exec_t) ( |
286 | 293 |
|
287 | 294 | typedef void (*zend_async_queue_task_t)(zend_async_task_t *task); |
288 | 295 |
|
| 296 | +typedef void (*zend_async_task_run_t)(zend_async_task_t *task); |
| 297 | + |
289 | 298 | typedef void (*zend_async_microtask_handler_t)(zend_async_microtask_t *microtask); |
290 | 299 |
|
291 | 300 | struct _zend_fcall_s { |
@@ -732,6 +741,7 @@ struct _zend_async_listen_event_s { |
732 | 741 |
|
733 | 742 | struct _zend_async_task_s { |
734 | 743 | zend_async_event_t base; |
| 744 | + zend_async_task_run_t run; |
735 | 745 | }; |
736 | 746 |
|
737 | 747 | struct _zend_async_trigger_event_s { |
@@ -1259,8 +1269,13 @@ ZEND_API extern zend_async_get_coroutines_t zend_async_get_coroutines_fn; |
1259 | 1269 | ZEND_API extern zend_async_add_microtask_t zend_async_add_microtask_fn; |
1260 | 1270 | ZEND_API extern zend_async_get_awaiting_info_t zend_async_get_awaiting_info_fn; |
1261 | 1271 | ZEND_API extern zend_async_get_class_ce_t zend_async_get_class_ce_fn; |
1262 | | -ZEND_API extern zend_async_future_create_t zend_async_future_create_fn; |
1263 | | -ZEND_API extern zend_async_channel_create_t zend_async_channel_create_fn; |
| 1272 | +ZEND_API extern zend_async_new_future_t zend_async_new_future_fn; |
| 1273 | +ZEND_API extern zend_async_new_channel_t zend_async_new_channel_fn; |
| 1274 | +ZEND_API extern zend_async_new_future_obj_t zend_async_new_future_obj_fn; |
| 1275 | +ZEND_API extern zend_async_new_channel_obj_t zend_async_new_channel_obj_fn; |
| 1276 | + |
| 1277 | +/* GROUP API */ |
| 1278 | +ZEND_API extern zend_async_new_group_t zend_async_new_group_fn; |
1264 | 1279 |
|
1265 | 1280 | /* Iterator API */ |
1266 | 1281 | ZEND_API extern zend_async_new_iterator_t zend_async_new_iterator_fn; |
@@ -1335,6 +1350,11 @@ ZEND_API bool zend_async_scheduler_register( |
1335 | 1350 | zend_async_get_awaiting_info_t get_awaiting_info_fn, |
1336 | 1351 | zend_async_get_class_ce_t get_class_ce_fn, |
1337 | 1352 | zend_async_new_iterator_t new_iterator_fn, |
| 1353 | + zend_async_new_future_t new_future_fn, |
| 1354 | + zend_async_new_channel_t new_channel_fn, |
| 1355 | + zend_async_new_future_obj_t new_future_obj_fn, |
| 1356 | + zend_async_new_channel_obj_t new_channel_obj_fn, |
| 1357 | + zend_async_new_group_t new_group_fn, |
1338 | 1358 | zend_async_engine_shutdown_t engine_shutdown_fn |
1339 | 1359 | ); |
1340 | 1360 |
|
@@ -1446,12 +1466,18 @@ ZEND_API void zend_async_add_main_coroutine_start_handler( |
1446 | 1466 | ZEND_API void zend_async_call_main_coroutine_start_handlers(zend_coroutine_t *main_coroutine); |
1447 | 1467 |
|
1448 | 1468 | /* Future API Functions */ |
1449 | | -#define ZEND_ASYNC_NEW_FUTURE(thread_safe) zend_async_future_create_fn(thread_safe, 0) |
1450 | | -#define ZEND_ASYNC_NEW_FUTURE_EX(thread_safe, extra_size) zend_async_future_create_fn(thread_safe, extra_size) |
| 1469 | +#define ZEND_ASYNC_NEW_FUTURE(thread_safe) zend_async_new_future_fn(thread_safe, 0) |
| 1470 | +#define ZEND_ASYNC_NEW_FUTURE_EX(thread_safe, extra_size) zend_async_new_future_fn(thread_safe, extra_size) |
| 1471 | +#define ZEND_ASYNC_NEW_FUTURE_OBJ(future) zend_async_new_future_obj_fn(future) |
1451 | 1472 |
|
1452 | 1473 | /* Channel API Functions */ |
1453 | | -#define ZEND_ASYNC_NEW_CHANNEL(buffer_size, resizable, thread_safe) zend_async_channel_create_fn(buffer_size, resizable, thread_safe, 0) |
1454 | | -#define ZEND_ASYNC_NEW_CHANNEL_EX(buffer_size, resizable, thread_safe, extra_size) zend_async_channel_create_fn(buffer_size, resizable, thread_safe, extra_size) |
| 1474 | +#define ZEND_ASYNC_NEW_CHANNEL(buffer_size, resizable, thread_safe) zend_async_new_channel_fn(buffer_size, resizable, thread_safe, 0) |
| 1475 | +#define ZEND_ASYNC_NEW_CHANNEL_EX(buffer_size, resizable, thread_safe, extra_size) zend_async_new_channel_fn(buffer_size, resizable, thread_safe, extra_size) |
| 1476 | +#define ZEND_ASYNC_NEW_CHANNEL_OBJ(channel) zend_async_new_channel_obj_fn(channel) |
| 1477 | + |
| 1478 | +/* GROUP API Functions */ |
| 1479 | +#define ZEND_ASYNC_NEW_GROUP() zend_async_new_group_fn(0) |
| 1480 | +#define ZEND_ASYNC_NEW_GROUP_EX(extra_size) zend_async_new_group_fn(extra_size) |
1455 | 1481 |
|
1456 | 1482 | END_EXTERN_C() |
1457 | 1483 |
|
|
0 commit comments