Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::vm::profile_manager Struct Reference

#include <profile.hpp>

Public Member Functions

 profile_manager ()
 
void start (profile_data *data)
 
void stop ()
 
 ~profile_manager ()
 
 profile_manager ()
 
void start (profile_data *data)
 
void stop ()
 
 ~profile_manager ()
 

Static Public Member Functions

static profile_managerinstance ()
 
static profile_managerinstance ()
 

Public Attributes

std::mutex mutex
 
std::vector< pthread_t > threads_to_notify
 
std::thread timer_thread
 
bool done = false
 
std::condition_variable timer_cond
 

Detailed Description

Definition at line 358 of file profile.hpp.

Constructor & Destructor Documentation

◆ profile_manager() [1/2]

sysio::vm::profile_manager::profile_manager ( )
inline

Definition at line 359 of file profile.hpp.

359 {
361 timer_thread = std::thread([this]{
362 auto lock = std::unique_lock(mutex);
363 while(!timer_cond.wait_for(lock, std::chrono::microseconds(profile_interval_us), [&]{ return done; })) {
364 for(pthread_t notify : threads_to_notify) {
365 pthread_kill(notify, SIGPROF);
366 }
367 }
368 });
369 }
void register_profile_signal_handler()
Definition profile.hpp:264
uint32_t profile_interval_us
Definition profile.hpp:18
std::condition_variable timer_cond
Definition profile.hpp:398
std::vector< pthread_t > threads_to_notify
Definition profile.hpp:394
Here is the call graph for this function:

◆ ~profile_manager() [1/2]

sysio::vm::profile_manager::~profile_manager ( )
inline

Definition at line 381 of file profile.hpp.

381 {
382 {
383 auto lock = std::scoped_lock(mutex);
384 done = true;
385 }
386 timer_cond.notify_one();
387 timer_thread.join();
388 }

◆ profile_manager() [2/2]

sysio::vm::profile_manager::profile_manager ( )
inline

Definition at line 359 of file profile.hpp.

359 {
361 timer_thread = std::thread([this]{
362 auto lock = std::unique_lock(mutex);
363 while(!timer_cond.wait_for(lock, std::chrono::microseconds(profile_interval_us), [&]{ return done; })) {
364 for(pthread_t notify : threads_to_notify) {
365 pthread_kill(notify, SIGPROF);
366 }
367 }
368 });
369 }
Here is the call graph for this function:

◆ ~profile_manager() [2/2]

sysio::vm::profile_manager::~profile_manager ( )
inline

Definition at line 381 of file profile.hpp.

381 {
382 {
383 auto lock = std::scoped_lock(mutex);
384 done = true;
385 }
386 timer_cond.notify_one();
387 timer_thread.join();
388 }

Member Function Documentation

◆ instance() [1/2]

static profile_manager & sysio::vm::profile_manager::instance ( )
inlinestatic

Definition at line 389 of file profile.hpp.

389 {
390 static profile_manager result;
391 return result;
392 }
Here is the caller graph for this function:

◆ instance() [2/2]

static profile_manager & sysio::vm::profile_manager::instance ( )
inlinestatic

Definition at line 389 of file profile.hpp.

389 {
390 static profile_manager result;
391 return result;
392 }

◆ start() [1/2]

void sysio::vm::profile_manager::start ( profile_data * data)
inline

Definition at line 370 of file profile.hpp.

370 {
371 auto lock = std::lock_guard(mutex);
372
373 per_thread_profile_data = data;
374 threads_to_notify.push_back(pthread_self());
375 }
Here is the caller graph for this function:

◆ start() [2/2]

void sysio::vm::profile_manager::start ( profile_data * data)
inline

Definition at line 370 of file profile.hpp.

370 {
371 auto lock = std::lock_guard(mutex);
372
373 per_thread_profile_data = data;
374 threads_to_notify.push_back(pthread_self());
375 }

◆ stop() [1/2]

void sysio::vm::profile_manager::stop ( )
inline

Definition at line 376 of file profile.hpp.

376 {
377 per_thread_profile_data = nullptr;
378 auto lock = std::lock_guard(mutex);
379 threads_to_notify.erase(std::find(threads_to_notify.begin(), threads_to_notify.end(), pthread_self()));
380 }
Here is the caller graph for this function:

◆ stop() [2/2]

void sysio::vm::profile_manager::stop ( )
inline

Definition at line 376 of file profile.hpp.

376 {
377 per_thread_profile_data = nullptr;
378 auto lock = std::lock_guard(mutex);
379 threads_to_notify.erase(std::find(threads_to_notify.begin(), threads_to_notify.end(), pthread_self()));
380 }

Member Data Documentation

◆ done

bool sysio::vm::profile_manager::done = false

Definition at line 397 of file profile.hpp.

◆ mutex

std::mutex sysio::vm::profile_manager::mutex

Definition at line 393 of file profile.hpp.

◆ threads_to_notify

std::vector< pthread_t > sysio::vm::profile_manager::threads_to_notify

Definition at line 394 of file profile.hpp.

◆ timer_cond

std::condition_variable sysio::vm::profile_manager::timer_cond

Definition at line 398 of file profile.hpp.

◆ timer_thread

std::thread sysio::vm::profile_manager::timer_thread

Definition at line 396 of file profile.hpp.


The documentation for this struct was generated from the following files: