Lines Matching refs:fiber
49 static zend_fiber_transfer zend_test_fiber_resume(zend_test_fiber *fiber, zval *value, bool excepti… in zend_test_fiber_resume() argument
53 fiber->caller = EG(current_fiber_context); in zend_test_fiber_resume()
54 ZT_G(active_fiber) = fiber; in zend_test_fiber_resume()
56 zend_fiber_transfer transfer = zend_test_fiber_switch_to(fiber->previous, value, exception); in zend_test_fiber_resume()
63 static zend_fiber_transfer zend_test_fiber_suspend(zend_test_fiber *fiber, zval *value) in zend_test_fiber_suspend() argument
65 ZEND_ASSERT(fiber->caller != NULL); in zend_test_fiber_suspend()
67 zend_fiber_context *caller = fiber->caller; in zend_test_fiber_suspend()
68 fiber->previous = EG(current_fiber_context); in zend_test_fiber_suspend()
69 fiber->caller = NULL; in zend_test_fiber_suspend()
76 zend_test_fiber *fiber = ZT_G(active_fiber); in zend_test_fiber_execute() local
99 fiber->fci.retval = &retval; in zend_test_fiber_execute()
101 zend_call_function(&fiber->fci, &fiber->fci_cache); in zend_test_fiber_execute()
103 zval_ptr_dtor(&fiber->result); // Destroy param from symmetric coroutine. in zend_test_fiber_execute()
104 zval_ptr_dtor(&fiber->fci.function_name); in zend_test_fiber_execute()
107 if (!(fiber->flags & ZEND_FIBER_FLAG_DESTROYED) in zend_test_fiber_execute()
110 fiber->flags |= ZEND_FIBER_FLAG_THREW; in zend_test_fiber_execute()
118 ZVAL_COPY_VALUE(&fiber->result, &retval); in zend_test_fiber_execute()
119 ZVAL_COPY(&transfer->value, &fiber->result); in zend_test_fiber_execute()
122 fiber->flags |= ZEND_FIBER_FLAG_BAILOUT; in zend_test_fiber_execute()
128 if (fiber->target) { in zend_test_fiber_execute()
129 zend_fiber_context *target = &fiber->target->context; in zend_test_fiber_execute()
133 ZVAL_COPY(&fiber->target->result, &fiber->result); in zend_test_fiber_execute()
134 fiber->target->fci.params = &fiber->target->result; in zend_test_fiber_execute()
135 fiber->target->fci.param_count = 1; in zend_test_fiber_execute()
137 fiber->target->caller = fiber->caller; in zend_test_fiber_execute()
138 ZT_G(active_fiber) = fiber->target; in zend_test_fiber_execute()
140 transfer->context = fiber->caller; in zend_test_fiber_execute()
143 fiber->caller = NULL; in zend_test_fiber_execute()
148 zend_test_fiber *fiber; in zend_test_fiber_object_create() local
150 fiber = emalloc(sizeof(zend_test_fiber)); in zend_test_fiber_object_create()
151 memset(fiber, 0, sizeof(zend_test_fiber)); in zend_test_fiber_object_create()
153 zend_object_std_init(&fiber->std, ce); in zend_test_fiber_object_create()
154 fiber->std.handlers = &zend_test_fiber_handlers; in zend_test_fiber_object_create()
156 return &fiber->std; in zend_test_fiber_object_create()
161 zend_test_fiber *fiber = (zend_test_fiber *) object; in zend_test_fiber_object_destroy() local
163 if (fiber->context.status != ZEND_FIBER_STATUS_SUSPENDED) { in zend_test_fiber_object_destroy()
170 fiber->flags |= ZEND_FIBER_FLAG_DESTROYED; in zend_test_fiber_object_destroy()
172 zend_fiber_transfer transfer = zend_test_fiber_resume(fiber, NULL, false); in zend_test_fiber_object_destroy()
195 zend_test_fiber *fiber = (zend_test_fiber *) object; in zend_test_fiber_object_free() local
197 if (fiber->context.status == ZEND_FIBER_STATUS_INIT) { in zend_test_fiber_object_free()
199 zval_ptr_dtor(&fiber->fci.function_name); in zend_test_fiber_object_free()
202 if (fiber->target) { in zend_test_fiber_object_free()
203 OBJ_RELEASE(&fiber->target->std); in zend_test_fiber_object_free()
206 zval_ptr_dtor(&fiber->result); in zend_test_fiber_object_free()
208 zend_object_std_dtor(&fiber->std); in zend_test_fiber_object_free()
212 zend_test_fiber *fiber, zend_fiber_transfer *transfer, INTERNAL_FUNCTION_PARAMETERS in delegate_transfer_result() argument
219 if (fiber->context.status == ZEND_FIBER_STATUS_DEAD) { in delegate_transfer_result()
229 zend_test_fiber *fiber = (zend_test_fiber *) Z_OBJ_P(getThis()); in ZEND_METHOD() local
232 Z_PARAM_FUNC(fiber->fci, fiber->fci_cache) in ZEND_METHOD()
236 Z_TRY_ADDREF(fiber->fci.function_name); in ZEND_METHOD()
241 zend_test_fiber *fiber = (zend_test_fiber *) Z_OBJ_P(getThis()); in ZEND_METHOD() local
250 ZEND_ASSERT(fiber->context.status == ZEND_FIBER_STATUS_INIT); in ZEND_METHOD()
252 if (fiber->previous != NULL) { in ZEND_METHOD()
257 fiber->fci.params = params; in ZEND_METHOD()
258 fiber->fci.param_count = param_count; in ZEND_METHOD()
259 fiber->fci.named_params = named_params; in ZEND_METHOD()
261 …zend_fiber_init_context(&fiber->context, zend_test_fiber_class, zend_test_fiber_execute, EG(fiber_… in ZEND_METHOD()
263 fiber->previous = &fiber->context; in ZEND_METHOD()
265 zend_fiber_transfer transfer = zend_test_fiber_resume(fiber, NULL, false); in ZEND_METHOD()
267 delegate_transfer_result(fiber, &transfer, INTERNAL_FUNCTION_PARAM_PASSTHRU); in ZEND_METHOD()
279 zend_test_fiber *fiber = ZT_G(active_fiber); in ZEND_METHOD() local
281 ZEND_ASSERT(fiber); in ZEND_METHOD()
283 zend_fiber_transfer transfer = zend_test_fiber_suspend(fiber, value); in ZEND_METHOD()
285 if (fiber->flags & ZEND_FIBER_FLAG_DESTROYED) { in ZEND_METHOD()
292 delegate_transfer_result(fiber, &transfer, INTERNAL_FUNCTION_PARAM_PASSTHRU); in ZEND_METHOD()
297 zend_test_fiber *fiber; in ZEND_METHOD() local
305 fiber = (zend_test_fiber *) Z_OBJ_P(getThis()); in ZEND_METHOD()
307 if (UNEXPECTED(fiber->context.status != ZEND_FIBER_STATUS_SUSPENDED || fiber->caller != NULL)) { in ZEND_METHOD()
312 zend_fiber_transfer transfer = zend_test_fiber_resume(fiber, value, false); in ZEND_METHOD()
314 delegate_transfer_result(fiber, &transfer, INTERNAL_FUNCTION_PARAM_PASSTHRU); in ZEND_METHOD()
326 zend_test_fiber *fiber = (zend_test_fiber *) Z_OBJ_P(getThis()); in ZEND_METHOD() local
333 target->previous = &fiber->context; in ZEND_METHOD()
335 if (fiber->target) { in ZEND_METHOD()
336 OBJ_RELEASE(&fiber->target->std); in ZEND_METHOD()
339 fiber->target = target; in ZEND_METHOD()