yse / easy_profiler

Lightweight profiler library for c++
MIT License
2.14k stars 184 forks source link

[Question] how to prevent multithread problem in chunk_alloctor? #211

Open gggin opened 9 months ago

gggin commented 9 months ago
  1. chunk_allocator allocate function change last pointer when memory need be allocate
  2. chunk_allocator invert function will be called in serialize function and also use last->prev and last pointer

Question1: 1 and 2 will cause multithread problem? Question2: if Question 1 is true, where is code to handle this, or this is a bug?

gggin commented 6 months ago

After some survey I find:

ProfileManager::dumpBlocksToStream function will set m_profilerStatus.store(false, std::memory_order_release); that isEnable be setted into false and every endBlock function will check this atomic variable and then give all endBlock 20ms to finish calls

so endBlock 's call chunk_allocator's allocate function will never call with serialize function