fiber: add fiber_set_ctx & fiber_get_ctx functions
Before this change there was no way to create a fiber that accepts parameters without yielding from the current fiber using the c api. You could pass the function arguments when calling fiber_start, but that forces you to yield, which is not acceptable in some scenarios (e.g. within a transaction). This commit introduces 2 new functions to the api: fiber_set_ctx for setting an pointer to a context of the given fiber and fiber_get_ctx for accessing that context. Closes https://github.com/tarantool/tarantool/issues/7669 @TarantoolBot document Title: fiber: add fiber_set_ctx & fiber_get_ctx functions Add 2 api functions: `fiber_set_ctx` & `fiber_get_ctx` which can be used for passing data to a fiber. Previously this could be done via the `fiber_start` function, except that this would force the current fiber to yield, which is not acceptable in some scenarios (e.g. during a transaction). Now you can create a fiber with `fiber_new`, set it's contents with `fiber_set_ctx`, make it ready for execution with `fiber_wakeup` and keep executing the current fiber.
Showing
- changelogs/unreleased/add-fiber_set_ctx.md 4 additions, 0 deletionschangelogs/unreleased/add-fiber_set_ctx.md
- extra/exports 2 additions, 0 deletionsextra/exports
- src/lib/core/fiber.c 12 additions, 0 deletionssrc/lib/core/fiber.c
- src/lib/core/fiber.h 21 additions, 0 deletionssrc/lib/core/fiber.h
- test/app-tap/module_api.c 27 additions, 0 deletionstest/app-tap/module_api.c
- test/app-tap/module_api.test.lua 1 addition, 1 deletiontest/app-tap/module_api.test.lua
Loading
Please register or sign in to comment