NCBI C++ ToolKit
Classes | Functions | Variables
MT-safety Testing Framework
+ Collaboration diagram for MT-safety Testing Framework:

Classes

class  CThreadedApp
 CThreadedApp –. More...
 
struct  CThreadedApp::SThreadGroup
 Thread group description parameters. More...
 

Functions

 CThreadedApp::CThreadedApp (void)
 Constructor. More...
 
 CThreadedApp::~CThreadedApp (void)
 Destructor. More...
 
virtual bool CThreadedApp::Thread_Init (int idx)
 Initialize the thread. More...
 
virtual bool CThreadedApp::Thread_Run (int idx)
 Run the thread. More...
 
virtual bool CThreadedApp::Thread_Exit (int idx)
 Exit the thread. More...
 
virtual bool CThreadedApp::Thread_Destroy (int idx)
 Destroy the thread. More...
 
virtual bool CThreadedApp::TestApp_Args (CArgDescriptions &args)
 Override this method to add your custom arguments. More...
 
virtual bool CThreadedApp::TestApp_Init (void)
 Override this method to execute code before running threads. More...
 
virtual bool CThreadedApp::TestApp_Exit (void)
 Override this method to execute code after all threads terminate. More...
 
void CThreadedApp::TestApp_IntraGroupSyncPoint (void)
 Wait until other threads in group reach the same sync point The call may be ignored by the application. More...
 
void CThreadedApp::TestApp_GlobalSyncPoint (void)
 Wait until ALL threads reach a call of TestApp_GlobalSyncPoint(). More...
 
void CThreadedApp::SetNumberOfDelayedStartSyncPoints (unsigned int num_min, unsigned int num_max)
 Set allowed range of delayed-start sync points. More...
 
void CThreadedApp::TestApp_DelayedStartSyncPoint (const string &name)
 Start threads that belong to delayed group (this call may be ignored to provide more randomness). More...
 
void CThreadedApp::Init (void)
 Initialize the app. More...
 
int CThreadedApp::Run (void)
 Run the threads. More...
 
void CThreadedApp::x_InitializeThreadGroups (void)
 
void CThreadedApp::x_PrintThreadGroups (void)
 
unsigned int CThreadedApp::x_InitializeDelayedStart (void)
 
void CThreadedApp::x_StartThreadGroup (unsigned int count)
 

Variables

const unsigned int k_NumThreadsMin = 1
 Minimum number of threads. More...
 
const unsigned int k_NumThreadsMax = 500
 Maximum number of threads. More...
 
const int k_SpawnByMin = 1
 Minimum number of spawn by threads. More...
 
const int k_SpawnByMax = 100
 Maximum number of spawn by threads. More...
 
unsigned int s_NumThreads
 
int s_SpawnBy
 
unsigned int CThreadedApp::SThreadGroup::number_of_threads
 Number of threads in the group. More...
 
bool CThreadedApp::SThreadGroup::has_sync_point
 TRUE, if the group has intra-group sync point. More...
 
CFastMutex CThreadedApp::m_AppMutex
 
set< stringCThreadedApp::m_Reached
 
unsigned int CThreadedApp::m_Min
 
unsigned int CThreadedApp::m_Max
 
volatile unsigned int CThreadedApp::m_NextGroup
 
vector< unsigned intCThreadedApp::m_Delayed
 
vector< SThreadGroupCThreadedApp::m_ThreadGroups
 
unsigned int CThreadedApp::m_LogMsgCount
 

Detailed Description

Function Documentation

◆ CThreadedApp()

CThreadedApp::CThreadedApp ( void  )

Constructor.

Override constructor to initialize the application.

Definition at line 448 of file test_mt.cpp.

References CThread::InitializeMainThreadId(), CThreadedApp::m_LogMsgCount, CThreadedApp::m_Max, CThreadedApp::m_Min, CThreadedApp::m_NextGroup, and s_Application.

◆ Init()

void CThreadedApp::Init ( void  )
privatevirtual

◆ Run()

int CThreadedApp::Run ( void  )
privatevirtual

◆ SetNumberOfDelayedStartSyncPoints()

void CThreadedApp::SetNumberOfDelayedStartSyncPoints ( unsigned int  num_min,
unsigned int  num_max 
)
protected

Set allowed range of delayed-start sync points.

The real number will be chosen randomly. Note: Specifying wrong number will cause inner assert() to fail

Definition at line 791 of file test_mt.cpp.

References CThreadedApp::m_Max, and CThreadedApp::m_Min.

◆ TestApp_Args()

bool CThreadedApp::TestApp_Args ( CArgDescriptions args)
protectedvirtual

Override this method to add your custom arguments.

Returns
TRUE on success, and FALSE on failure.

Definition at line 755 of file test_mt.cpp.

Referenced by CThreadedApp::Init().

◆ TestApp_DelayedStartSyncPoint()

void CThreadedApp::TestApp_DelayedStartSyncPoint ( const string name)
protected

Start threads that belong to delayed group (this call may be ignored to provide more randomness).

Note
anywhere in the middle.
Parameters
nameName can be anything you like, providing other threads use the same name. The test application distinguishes delayed-start sync points by name.

Definition at line 799 of file test_mt.cpp.

References set< Key, Compare >::end(), set< Key, Compare >::find(), set< Key, Compare >::insert(), CThreadedApp::m_AppMutex, CThreadedApp::m_Delayed, CThreadedApp::m_Reached, set< Key, Compare >::size(), and CThreadedApp::x_StartThreadGroup().

◆ TestApp_Exit()

bool CThreadedApp::TestApp_Exit ( void  )
protectedvirtual

Override this method to execute code after all threads terminate.

Returns
TRUE on success, and FALSE on failure.

Definition at line 811 of file test_mt.cpp.

Referenced by CThreadedApp::Run().

◆ TestApp_GlobalSyncPoint()

void CThreadedApp::TestApp_GlobalSyncPoint ( void  )
protected

Wait until ALL threads reach a call of TestApp_GlobalSyncPoint().

Warning
You can use this method if you want threads to be synchronized across different branches of code. The only thing to keep in mind is that EVERY thread has to reach TestApp_GlobalSyncPoint() for execution to be continued.
Note
Calling TestApp_GlobalSyncPoint() automatically awakes all threads that would be otherwise awaken only with TestApp_DelayedStartSyncPoint().

Definition at line 773 of file test_mt.cpp.

References i, set< Key, Compare >::insert(), CThreadedApp::m_AppMutex, CThreadedApp::m_Delayed, CThreadedApp::m_Reached, s_ThreadIdxTLS, set< Key, Compare >::size(), NStr::SizetToString(), TESTAPP_LOG_POST, thr, and CThreadedApp::x_StartThreadGroup().

◆ TestApp_Init()

bool CThreadedApp::TestApp_Init ( void  )
protectedvirtual

Override this method to execute code before running threads.

Returns
TRUE on success, and FALSE on failure.

Definition at line 760 of file test_mt.cpp.

Referenced by CThreadedApp::Run().

◆ TestApp_IntraGroupSyncPoint()

void CThreadedApp::TestApp_IntraGroupSyncPoint ( void  )
protected

Wait until other threads in group reach the same sync point The call may be ignored by the application.

Definition at line 766 of file test_mt.cpp.

References int, s_ThreadIdxTLS, and thr.

◆ Thread_Destroy()

bool CThreadedApp::Thread_Destroy ( int  idx)
virtual

Destroy the thread.

Called from thread's destroy() method.

Returns
TRUE on success, and FALSE on failure.

Definition at line 750 of file test_mt.cpp.

◆ Thread_Exit()

bool CThreadedApp::Thread_Exit ( int  idx)
virtual

Exit the thread.

Called from thread's OnExit() method.

Returns
TRUE on success, and FALSE on failure.

Definition at line 744 of file test_mt.cpp.

Referenced by CTestThread::OnExit().

◆ Thread_Init()

bool CThreadedApp::Thread_Init ( int  idx)
virtual

Initialize the thread.

Called from thread's constructor.

Returns
TRUE on success, and FALSE on failure.

Definition at line 732 of file test_mt.cpp.

Referenced by CTestThread::CTestThread().

◆ Thread_Run()

bool CThreadedApp::Thread_Run ( int  idx)
virtual

Run the thread.

Called from thread's Main() method.

Returns
TRUE on success, and FALSE on failure.

Definition at line 738 of file test_mt.cpp.

Referenced by CInGroupThread::Main().

◆ x_InitializeDelayedStart()

unsigned int CThreadedApp::x_InitializeDelayedStart ( void  )
private

◆ x_InitializeThreadGroups()

void CThreadedApp::x_InitializeThreadGroups ( void  )
private

◆ x_PrintThreadGroups()

void CThreadedApp::x_PrintThreadGroups ( void  )
private

◆ x_StartThreadGroup()

void CThreadedApp::x_StartThreadGroup ( unsigned int  count)
private

◆ ~CThreadedApp()

CThreadedApp::~CThreadedApp ( void  )

Destructor.

Definition at line 458 of file test_mt.cpp.

References s_Application.

Variable Documentation

◆ has_sync_point

bool CThreadedApp::SThreadGroup::has_sync_point

TRUE, if the group has intra-group sync point.

Definition at line 135 of file test_mt.hpp.

Referenced by CThreadedApp::x_InitializeThreadGroups().

◆ k_NumThreadsMax

const unsigned int k_NumThreadsMax = 500

Maximum number of threads.

Definition at line 57 of file test_mt.hpp.

Referenced by CThreadedApp::Init().

◆ k_NumThreadsMin

const unsigned int k_NumThreadsMin = 1

Minimum number of threads.

Definition at line 54 of file test_mt.hpp.

Referenced by CThreadedApp::Init().

◆ k_SpawnByMax

const int k_SpawnByMax = 100

Maximum number of spawn by threads.

Definition at line 63 of file test_mt.hpp.

Referenced by CThreadedApp::Init().

◆ k_SpawnByMin

const int k_SpawnByMin = 1

Minimum number of spawn by threads.

Definition at line 60 of file test_mt.hpp.

Referenced by CThreadedApp::Init().

◆ m_AppMutex

CFastMutex CThreadedApp::m_AppMutex
private

◆ m_Delayed

vector<unsigned int> CThreadedApp::m_Delayed
private

◆ m_LogMsgCount

unsigned int CThreadedApp::m_LogMsgCount
protected

Definition at line 210 of file test_mt.hpp.

Referenced by CThreadedApp::CThreadedApp().

◆ m_Max

unsigned int CThreadedApp::m_Max
private

◆ m_Min

unsigned int CThreadedApp::m_Min
private

◆ m_NextGroup

volatile unsigned int CThreadedApp::m_NextGroup
private

◆ m_Reached

set<string> CThreadedApp::m_Reached
private

◆ m_ThreadGroups

vector<SThreadGroup> CThreadedApp::m_ThreadGroups
private

◆ number_of_threads

unsigned int CThreadedApp::SThreadGroup::number_of_threads

Number of threads in the group.

Definition at line 133 of file test_mt.hpp.

Referenced by CThreadedApp::x_InitializeThreadGroups().

◆ s_NumThreads

unsigned int s_NumThreads
extern

◆ s_SpawnBy

int s_SpawnBy
extern
Modified on Sun Mar 03 03:17:18 2024 by modify_doxy.py rev. 669887