@@ -119,6 +119,11 @@ typedef enum
119
119
* zend_coroutine_t is a Basic data structure that represents a coroutine in the Zend Engine.
120
120
*/
121
121
typedef struct _zend_coroutine_s zend_coroutine_t ;
122
+
123
+ /**
124
+ * zend_future_t is a data structure that represents a future result container.
125
+ */
126
+ typedef struct _zend_future_s zend_future_t ;
122
127
typedef struct _zend_async_context_s zend_async_context_t ;
123
128
typedef struct _zend_async_waker_s zend_async_waker_t ;
124
129
typedef struct _zend_async_microtask_s zend_async_microtask_t ;
@@ -127,6 +132,9 @@ typedef struct _zend_async_iterator_s zend_async_iterator_t;
127
132
typedef struct _zend_fcall_s zend_fcall_t ;
128
133
typedef void (* zend_coroutine_entry_t )(void );
129
134
135
+ /* Future resolve function type */
136
+ typedef void (* zend_future_resolve_t )(zend_future_t * future , zval * value , zend_object * exception , bool transfer_error );
137
+
130
138
/* Coroutine Switch Handlers */
131
139
typedef struct _zend_coroutine_switch_handler_s zend_coroutine_switch_handler_t ;
132
140
typedef struct _zend_coroutine_switch_handlers_vector_s zend_coroutine_switch_handlers_vector_t ;
@@ -203,6 +211,7 @@ typedef zend_array* (*zend_async_get_coroutines_t)(void);
203
211
typedef void (* zend_async_add_microtask_t )(zend_async_microtask_t * microtask );
204
212
typedef zend_array * (* zend_async_get_awaiting_info_t )(zend_coroutine_t * coroutine );
205
213
typedef zend_class_entry * (* zend_async_get_class_ce_t )(zend_async_class type );
214
+ typedef zend_future_t * (* zend_async_future_create_t )(bool thread_safe , size_t extra_size );
206
215
207
216
typedef void (* zend_async_reactor_startup_t )(void );
208
217
typedef void (* zend_async_reactor_shutdown_t )(void );
@@ -963,6 +972,25 @@ struct _zend_coroutine_s {
963
972
zend_coroutine_switch_handlers_vector_t * switch_handlers ;
964
973
};
965
974
975
+ /**
976
+ * zend_future_t structure represents a future result container.
977
+ * It inherits from zend_async_event_t to participate in the event system.
978
+ */
979
+ struct _zend_future_s {
980
+ zend_async_event_t event ; /* Event inheritance (first member) */
981
+ zval result ; /* Result value (UNDEF = pending) */
982
+ zend_object * exception ; /* Exception object (NULL = no error) */
983
+
984
+ /* Debug information */
985
+ zend_string * filename ; /* Creation file */
986
+ uint32_t lineno ; /* Creation line */
987
+ zend_string * resolved_filename ; /* Resolution file */
988
+ uint32_t resolved_lineno ; /* Resolution line */
989
+
990
+ /* Resolution method */
991
+ zend_future_resolve_t resolve ;
992
+ };
993
+
966
994
/**
967
995
* The macro evaluates to TRUE if the coroutine is in a waiting state —
968
996
* either waiting for events or waiting in the execution queue.
@@ -1177,6 +1205,7 @@ ZEND_API extern zend_async_get_coroutines_t zend_async_get_coroutines_fn;
1177
1205
ZEND_API extern zend_async_add_microtask_t zend_async_add_microtask_fn ;
1178
1206
ZEND_API extern zend_async_get_awaiting_info_t zend_async_get_awaiting_info_fn ;
1179
1207
ZEND_API extern zend_async_get_class_ce_t zend_async_get_class_ce_fn ;
1208
+ ZEND_API extern zend_async_future_create_t zend_async_future_create_fn ;
1180
1209
1181
1210
/* Iterator API */
1182
1211
ZEND_API extern zend_async_new_iterator_t zend_async_new_iterator_fn ;
@@ -1361,6 +1390,10 @@ ZEND_API void zend_async_add_main_coroutine_start_handler(
1361
1390
1362
1391
ZEND_API void zend_async_call_main_coroutine_start_handlers (zend_coroutine_t * main_coroutine );
1363
1392
1393
+ /* Future API Functions */
1394
+ #define ZEND_ASYNC_NEW_FUTURE (thread_safe ) zend_async_future_create_fn(thread_safe, 0)
1395
+ #define ZEND_ASYNC_NEW_FUTURE_EX (thread_safe , extra_size ) zend_async_future_create_fn(thread_safe, extra_size)
1396
+
1364
1397
END_EXTERN_C ()
1365
1398
1366
1399
#define ZEND_ASYNC_IS_ENABLED () zend_async_is_enabled()
0 commit comments