fiber: initialize thread-local cord on demand
We're planning to introduce a basic C API for user read views (EE-only). Like all other box C API functions, the new API functions will use the existing box error C API for reporting errors. The problem is that a read view created using C API should be usable from user threads (started with the pthread lib) while the box error C API doesn't work in user threads, because those threads don't have the cord pointer initialized (a diagnostic area is stored in a cord object). To address this issue, let's create a new cord object automatically on first use of cord() if it wasn't created explicitly. Automatically created object is destroyed at thread exit (to achieve that, we use the C++ RAII concept). Closes #7814 NO_DOC=The C API documentation doesn't say anything about threads. Let's keep it this way for now. We're planning to introduce a new C API to work with threads in C modules. We'll update the doc when it's ready.
Showing
- changelogs/unreleased/gh-7814-box-error-in-thread.md 4 additions, 0 deletionschangelogs/unreleased/gh-7814-box-error-in-thread.md
- src/lib/core/CMakeLists.txt 1 addition, 0 deletionssrc/lib/core/CMakeLists.txt
- src/lib/core/cord_on_demand.cc 53 additions, 0 deletionssrc/lib/core/cord_on_demand.cc
- src/lib/core/cord_on_demand.h 25 additions, 0 deletionssrc/lib/core/cord_on_demand.h
- src/lib/core/fiber.c 1 addition, 1 deletionsrc/lib/core/fiber.c
- src/lib/core/fiber.h 14 additions, 1 deletionsrc/lib/core/fiber.h
- test/unit/error.c 38 additions, 1 deletiontest/unit/error.c
Loading