arena_ctx.h 595 B

12345678910111213141516171819202122232425262728
  1. #pragma once
  2. #include <util/memory/segmented_string_pool.h>
  3. struct MemoryContextData;
  4. typedef struct MemoryContextData *MemoryContext;
  5. namespace NYql {
  6. class TArenaMemoryContext {
  7. public:
  8. TArenaMemoryContext();
  9. ~TArenaMemoryContext();
  10. static segmented_string_pool& GetCurrentPool() {
  11. return Current->Pool;
  12. }
  13. void Acquire();
  14. void Release();
  15. private:
  16. segmented_string_pool Pool;
  17. MemoryContext PrevContext = nullptr;
  18. MemoryContext MyContext = nullptr;
  19. static __thread TArenaMemoryContext* Current;
  20. TArenaMemoryContext* Prev = nullptr;
  21. };
  22. }