box: implement watcher infrastructure
Part of #6257 This commit introduces a C module that will later be used for implementation of the watchers API in both Lua and IPROTO. Key points: - A watcher callback can be registered for an arbitrary string key with box_register_watcher(). - Watcher callbacks are invoked in the background by the worker fiber. If a watcher is asynchronous (WATCHER_RUN_ASYNC flag set), the worker fiber will invoke the callback in a new fiber. - A newly registered watcher callback is scheduled for execution unconditionally after registration, and then whenever box_broadcast() is called for the specified key. - The caller may pass arbitrary data to box_broadcast() which will be stored internally and passed to registered callbacks. - A callback is not executed again until it acknowledges the last notification (explicitly by calling watcher_ack() or implicitly by returning if WATCHER_EXPLICIT_ACK is unset).
Showing
- src/box/CMakeLists.txt 1 addition, 0 deletionssrc/box/CMakeLists.txt
- src/box/box.cc 3 additions, 0 deletionssrc/box/box.cc
- src/box/watcher.c 426 additions, 0 deletionssrc/box/watcher.c
- src/box/watcher.h 262 additions, 0 deletionssrc/box/watcher.h
- test/unit/CMakeLists.txt 3 additions, 0 deletionstest/unit/CMakeLists.txt
- test/unit/watcher.c 530 additions, 0 deletionstest/unit/watcher.c
- test/unit/watcher.result 101 additions, 0 deletionstest/unit/watcher.result
Loading
Please register or sign in to comment