Skip to content

Commit 2896aec

Browse files
committed
+ enqueue_coroutine
1 parent 1b84735 commit 2896aec

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Zend/zend_async_API.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ static zend_coroutine_t * spawn(zend_async_scope_t *scope, zend_object *scope_pr
3434

3535
static void suspend(bool from_main) {}
3636

37+
static void enqueue_coroutine(zend_coroutine_t *coroutine)
38+
{
39+
ASYNC_THROW_ERROR("Async API is not enabled");
40+
}
41+
3742
static zend_async_context_t * new_context(void)
3843
{
3944
ASYNC_THROW_ERROR("Context API is not enabled");
@@ -60,6 +65,7 @@ zend_async_spawn_t zend_async_spawn_fn = spawn;
6065
zend_async_new_coroutine_t zend_async_new_coroutine_fn = NULL;
6166
zend_async_new_scope_t zend_async_new_scope_fn = NULL;
6267
zend_async_suspend_t zend_async_suspend_fn = suspend;
68+
zend_async_enqueue_coroutine_t zend_async_enqueue_coroutine_fn = enqueue_coroutine;
6369
zend_async_resume_t zend_async_resume_fn = NULL;
6470
zend_async_cancel_t zend_async_cancel_fn = NULL;
6571
zend_async_shutdown_t zend_async_shutdown_fn = NULL;
@@ -175,6 +181,7 @@ ZEND_API void zend_async_scheduler_register(
175181
zend_async_new_context_t new_context_fn,
176182
zend_async_spawn_t spawn_fn,
177183
zend_async_suspend_t suspend_fn,
184+
zend_async_enqueue_coroutine_t enqueue_coroutine_fn,
178185
zend_async_resume_t resume_fn,
179186
zend_async_cancel_t cancel_fn,
180187
zend_async_shutdown_t shutdown_fn,
@@ -203,6 +210,7 @@ ZEND_API void zend_async_scheduler_register(
203210
zend_async_new_context_fn = new_context_fn;
204211
zend_async_spawn_fn = spawn_fn;
205212
zend_async_suspend_fn = suspend_fn;
213+
zend_async_enqueue_coroutine_fn = enqueue_coroutine_fn;
206214
zend_async_resume_fn = resume_fn;
207215
zend_async_cancel_fn = cancel_fn;
208216
zend_async_shutdown_fn = shutdown_fn;

Zend/zend_async_API.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ typedef zend_coroutine_t * (*zend_async_new_coroutine_t)(zend_async_scope_t *sco
159159
typedef zend_async_scope_t * (*zend_async_new_scope_t)(zend_async_scope_t * parent_scope);
160160
typedef zend_coroutine_t * (*zend_async_spawn_t)(zend_async_scope_t *scope, zend_object *scope_provider);
161161
typedef void (*zend_async_suspend_t)(bool from_main);
162+
typedef void (*zend_async_enqueue_coroutine_t)(zend_coroutine_t *coroutine);
162163
typedef void (*zend_async_resume_t)(zend_coroutine_t *coroutine, zend_object * error, const bool transfer_error);
163164
typedef void (*zend_async_cancel_t)(zend_coroutine_t *coroutine, zend_object * error, const bool transfer_error, const bool is_safely);
164165
typedef void (*zend_async_shutdown_t)(void);
@@ -866,6 +867,7 @@ ZEND_API extern zend_async_spawn_t zend_async_spawn_fn;
866867
ZEND_API extern zend_async_new_coroutine_t zend_async_new_coroutine_fn;
867868
ZEND_API extern zend_async_new_scope_t zend_async_new_scope_fn;
868869
ZEND_API extern zend_async_suspend_t zend_async_suspend_fn;
870+
ZEND_API extern zend_async_enqueue_coroutine_t zend_async_enqueue_coroutine_fn;
869871
ZEND_API extern zend_async_resume_t zend_async_resume_fn;
870872
ZEND_API extern zend_async_cancel_t zend_async_cancel_fn;
871873
ZEND_API extern zend_async_shutdown_t zend_async_shutdown_fn;
@@ -913,6 +915,7 @@ ZEND_API void zend_async_scheduler_register(
913915
zend_async_new_context_t new_context_fn,
914916
zend_async_spawn_t spawn_fn,
915917
zend_async_suspend_t suspend_fn,
918+
zend_async_enqueue_coroutine_t enqueue_coroutine_fn,
916919
zend_async_resume_t resume_fn,
917920
zend_async_cancel_t cancel_fn,
918921
zend_async_shutdown_t shutdown_fn,
@@ -986,6 +989,7 @@ END_EXTERN_C()
986989
#define ZEND_ASYNC_NEW_SCOPE(parent) zend_async_new_scope_fn(parent)
987990
#define ZEND_ASYNC_SUSPEND() zend_async_suspend_fn(false)
988991
#define ZEND_ASYNC_RUN_SCHEDULER_AFTER_MAIN() zend_async_suspend_fn(true)
992+
#define ZEND_ASYNC_ENQUEUE_COROUTINE(coroutine) zend_async_enqueue_coroutine_fn(coroutine)
989993
#define ZEND_ASYNC_RESUME(coroutine) zend_async_resume_fn(coroutine, NULL, false)
990994
#define ZEND_ASYNC_RESUME_WITH_ERROR(coroutine, error, transfer_error) zend_async_resume_fn(coroutine, error, transfer_error)
991995
#define ZEND_ASYNC_CANCEL(coroutine, error, transfer_error) zend_async_cancel_fn(coroutine, error, transfer_error, false)

0 commit comments

Comments
 (0)