Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
log4cxx::helpers::ThreadUtility Class Reference

#include <threadutility.h>

Public Types

using Period = std::chrono::milliseconds
using Manager = SingletonHolder<ThreadUtility>

Public Member Functions

 ~ThreadUtility ()
ThreadConfigurationType configureFuncs (ThreadStartPre pre_start, ThreadStarted set_name, ThreadStartPost post_start)
 Set call-back functions to use when starting a thread.
template<class Function, class... Args>
std::thread createThread (LogString name, Function &&f, Args &&... args)
 Start a thread.
void addPeriodicTask (const LogString &taskName, std::function< void()> f, const Period &delay)
 Add the taskName periodic task.
bool hasPeriodicTask (const LogString &taskName)
 Has a taskName periodic task already been added?
bool isProcessingThreadActive () const
 Is the processing thread running?
void removeAllPeriodicTasks ()
 Remove all periodic tasks and stop the processing thread.
void removePeriodicTask (const LogString &taskName)
 Remove the taskName periodic task.
void removePeriodicTasksMatching (const LogString &namePrefix)
 Remove any periodic task matching namePrefix.
 LOG4CXX_PTR_DEF (Manager)

Static Public Member Functions

static ThreadUtility * instance ()
static ThreadConfigurationType configure (ThreadConfigurationType new_value)
 Use new_value as the behviour when starting a thread.
static ManagerPtr instancePtr ()

Friends

class SingletonHolder< ThreadUtility >

Member Typedef Documentation

◆ Manager

◆ Period

using log4cxx::helpers::ThreadUtility::Period = std::chrono::milliseconds

Constructor & Destructor Documentation

◆ ~ThreadUtility()

log4cxx::helpers::ThreadUtility::~ThreadUtility ( )

Member Function Documentation

◆ addPeriodicTask()

void log4cxx::helpers::ThreadUtility::addPeriodicTask ( const LogString & taskName,
std::function< void()> f,
const Period & delay )

Add the taskName periodic task.

◆ configure()

ThreadConfigurationType log4cxx::helpers::ThreadUtility::configure ( ThreadConfigurationType new_value)
static

Use new_value as the behviour when starting a thread.

Call-back function pointers are reset to nullptr.

Returns
The previous configuration

◆ configureFuncs()

ThreadConfigurationType log4cxx::helpers::ThreadUtility::configureFuncs ( ThreadStartPre pre_start,
ThreadStarted set_name,
ThreadStartPost post_start )

Set call-back functions to use when starting a thread.

Note that setting any of these parameters to nullptr is valid, and simply results in the callback not being called.

Returns
The previous configuration

◆ createThread()

template<class Function, class... Args>
std::thread log4cxx::helpers::ThreadUtility::createThread ( LogString name,
Function && f,
Args &&... args )
inline

Start a thread.

◆ hasPeriodicTask()

bool log4cxx::helpers::ThreadUtility::hasPeriodicTask ( const LogString & taskName)

Has a taskName periodic task already been added?

◆ instance()

ThreadUtility * log4cxx::helpers::ThreadUtility::instance ( )
static

◆ instancePtr()

ManagerPtr log4cxx::helpers::ThreadUtility::instancePtr ( )
static

◆ isProcessingThreadActive()

bool log4cxx::helpers::ThreadUtility::isProcessingThreadActive ( ) const

Is the processing thread running?

◆ LOG4CXX_PTR_DEF()

log4cxx::helpers::ThreadUtility::LOG4CXX_PTR_DEF ( Manager )

◆ removeAllPeriodicTasks()

void log4cxx::helpers::ThreadUtility::removeAllPeriodicTasks ( )

Remove all periodic tasks and stop the processing thread.

◆ removePeriodicTask()

void log4cxx::helpers::ThreadUtility::removePeriodicTask ( const LogString & taskName)

Remove the taskName periodic task.

◆ removePeriodicTasksMatching()

void log4cxx::helpers::ThreadUtility::removePeriodicTasksMatching ( const LogString & namePrefix)

Remove any periodic task matching namePrefix.

◆ SingletonHolder< ThreadUtility >

friend class SingletonHolder< ThreadUtility >
friend

The documentation for this class was generated from the following file: