@@ -29,6 +29,7 @@ zend_class_entry *async_ce_input_output_exception = NULL;
2929zend_class_entry * async_ce_timeout_exception = NULL ;
3030zend_class_entry * async_ce_poll_exception = NULL ;
3131zend_class_entry * async_ce_dns_exception = NULL ;
32+ zend_class_entry * async_ce_deadlock_error = NULL ;
3233zend_class_entry * async_ce_composite_exception = NULL ;
3334
3435PHP_METHOD (Async_CompositeException , addException )
@@ -66,6 +67,7 @@ void async_register_exceptions_ce(void)
6667 async_ce_timeout_exception = register_class_Async_TimeoutException (zend_ce_exception );
6768 async_ce_poll_exception = register_class_Async_PollException (zend_ce_exception );
6869 async_ce_dns_exception = register_class_Async_DnsException (zend_ce_exception );
70+ async_ce_deadlock_error = register_class_Async_DeadlockError (zend_ce_error );
6971 async_ce_composite_exception = register_class_Async_CompositeException (zend_ce_exception );
7072}
7173
@@ -194,6 +196,26 @@ PHP_ASYNC_API ZEND_COLD zend_object *async_throw_poll(const char *format, ...)
194196 return obj ;
195197}
196198
199+ PHP_ASYNC_API ZEND_COLD zend_object * async_throw_deadlock (const char * format , ...)
200+ {
201+ format = format ? format : "A deadlock was detected" ;
202+
203+ va_list args ;
204+ va_start (args , format );
205+
206+ zend_object * obj = NULL ;
207+
208+ if (EXPECTED (EG (current_execute_data ))) {
209+ obj = zend_throw_exception_ex (async_ce_deadlock_error , 0 , format , args );
210+ } else {
211+ obj = async_new_exception (async_ce_deadlock_error , format , args );
212+ async_apply_exception_to_context (obj );
213+ }
214+
215+ va_end (args );
216+ return obj ;
217+ }
218+
197219PHP_ASYNC_API ZEND_COLD zend_object * async_new_composite_exception (void )
198220{
199221 zval composite ;
0 commit comments