Changeset View
Changeset View
Standalone View
Standalone View
source/ps/Profiler2.h
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | ||||||||||||||||||
*/ | */ | |||||||||||||||||
#ifndef INCLUDED_PROFILER2 | #ifndef INCLUDED_PROFILER2 | |||||||||||||||||
#define INCLUDED_PROFILER2 | #define INCLUDED_PROFILER2 | |||||||||||||||||
#include "lib/timer.h" | #include "lib/timer.h" | |||||||||||||||||
#include "ps/ThreadUtil.h" | #include "ps/ThreadUtil.h" | |||||||||||||||||
#include <atomic> | ||||||||||||||||||
#include <mutex> | #include <mutex> | |||||||||||||||||
#include <string> | #include <string> | |||||||||||||||||
#include <thread> | #include <thread> | |||||||||||||||||
#include <vector> | #include <vector> | |||||||||||||||||
struct mg_context; | struct mg_context; | |||||||||||||||||
// Note: Lots of functions are defined inline, to hypothetically | // Note: Lots of functions are defined inline, to hypothetically | |||||||||||||||||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | private: | |||||||||||||||||
// To allow hopefully-safe reading of the buffer from a separate thread, | // To allow hopefully-safe reading of the buffer from a separate thread, | |||||||||||||||||
// without any expensive synchronisation in the recording thread, | // without any expensive synchronisation in the recording thread, | |||||||||||||||||
// two copies of the current buffer write position are stored. | // two copies of the current buffer write position are stored. | |||||||||||||||||
// BufferPos0 is updated before writing; BufferPos1 is updated after writing. | // BufferPos0 is updated before writing; BufferPos1 is updated after writing. | |||||||||||||||||
// GetBuffer can read Pos1, copy the buffer, read Pos0, then assume any bytes | // GetBuffer can read Pos1, copy the buffer, read Pos0, then assume any bytes | |||||||||||||||||
// outside the range Pos1 <= x < Pos0 are safe to use. (Any in that range might | // outside the range Pos1 <= x < Pos0 are safe to use. (Any in that range might | |||||||||||||||||
// be half-written and corrupted.) (All ranges are modulo BUFFER_SIZE.) | // be half-written and corrupted.) (All ranges are modulo BUFFER_SIZE.) | |||||||||||||||||
// Outside of Write(), these will always be equal. | // Outside of Write(), these will always be equal. | |||||||||||||||||
// | std::atomic<u32> m_BufferPos0; | |||||||||||||||||
// TODO: does this attempt at synchronisation (plus use of COMPILER_FENCE etc) | std::atomic<u32> m_BufferPos1; | |||||||||||||||||
Stan: Can we find better names? Does it make sense to have them separate or should they be in a… | ||||||||||||||||||
phositAuthorUnsubmitted Done Inline Actions
Yes this names are not descriptive. phosit: Yes this names are not descriptive.
Something like this? | ||||||||||||||||||
Not Done Inline ActionsShould this be in ps/containers and or have tests? Stan: Should this be in ps/containers and or have tests? | ||||||||||||||||||
Done Inline ActionsIt doesn't have functionality (to test) on it's own. phosit: It doesn't have functionality (to test) on it's own. | ||||||||||||||||||
// actually work in practice? | ||||||||||||||||||
u32 m_BufferPos0; | ||||||||||||||||||
u32 m_BufferPos1; | ||||||||||||||||||
}; | }; | |||||||||||||||||
public: | public: | |||||||||||||||||
CProfiler2(); | CProfiler2(); | |||||||||||||||||
~CProfiler2(); | ~CProfiler2(); | |||||||||||||||||
/** | /** | |||||||||||||||||
* Call in main thread to set up the profiler, | * Call in main thread to set up the profiler, | |||||||||||||||||
▲ Show 20 Lines • Show All 281 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Can we find better names? Does it make sense to have them separate or should they be in a struct /tuple?