File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,30 @@ struct _zend_async_event_callback_s {
363
363
zend_async_event_callback_dispose_fn dispose ;
364
364
};
365
365
366
+ #define ZEND_ASYNC_EVENT_CALLBACK_ADD_REF (callback ) \
367
+ if (callback != NULL) { \
368
+ callback->ref_count++; \
369
+ }
370
+
371
+ //
372
+ // For a callback,
373
+ // it’s crucial that the reference count is always greater than zero,
374
+ // because a value of zero is a special case triggered from a destructor.
375
+ // If you need to “retain” ownership of the object,
376
+ // you **MUST** use either this macro or ZEND_ASYNC_EVENT_CALLBACK_RELEASE.
377
+ //
378
+ #define ZEND_ASYNC_EVENT_CALLBACK_DEC_REF (callback ) \
379
+ if(callback != NULL && callback->ref_count > 1) { \
380
+ callback->ref_count--; \
381
+ }
382
+
383
+ #define ZEND_ASYNC_EVENT_CALLBACK_RELEASE (callback ) \
384
+ if (callback != NULL && callback->ref_count > 1) { \
385
+ callback->ref_count--; \
386
+ } else { \
387
+ coroutine_event_callback_dispose(callback, NULL); \
388
+ }
389
+
366
390
struct _zend_coroutine_event_callback_s {
367
391
zend_async_event_callback_t base ;
368
392
zend_coroutine_t * coroutine ;
You can’t perform that action at this time.
0 commit comments