LibreOffice Module sw (master) 1
Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ThreadManager Class Referencefinal

class to manage threads More...

#include <threadmanager.hxx>

Collaboration diagram for ThreadManager:
[legend]

Classes

struct  ThreadPred
 
struct  tThreadData
 

Public Member Functions

 ThreadManager (css::uno::Reference< css::util::XJobManager > const &rThreadJoiner)
 
 ~ThreadManager ()
 
std::weak_ptr< IFinishedThreadListenerGetThreadListenerWeakRef () const
 
void NotifyAboutFinishedThread (const oslInterlockedCount nThreadID)
 
void Init ()
 initialization More...
 
oslInterlockedCount AddThread (const ::rtl::Reference< ObservableThread > &rThread)
 add thread to the thread manager and taking ownership for the thread More...
 
void RemoveThread (const oslInterlockedCount nThreadID, const bool bThreadFinished=false)
 
 DECL_LINK (TryToStartNewThread, Timer *, void)
 
void SuspendStartingOfThreads ()
 suspend the starting of threads More...
 
void ResumeStartingOfThreads ()
 continues the starting of threads after it has been suspended More...
 
bool StartingOfThreadsSuspended ()
 

Private Member Functions

bool StartWaitingThread ()
 
bool StartThread (const tThreadData &aThreadData)
 

Private Attributes

std::mutex maMutex
 
css::uno::WeakReference< css::util::XJobManager > mrThreadJoiner
 
std::shared_ptr< ThreadListenermpThreadListener
 
oslInterlockedCount mnThreadIDCounter
 
std::deque< tThreadDatamaWaitingForStartThreads
 
std::deque< tThreadDatamaStartedThreads
 
Idle maStartNewThreadIdle
 
bool mbStartingOfThreadsSuspended
 

Static Private Attributes

static const std::deque< tThreadData >::size_type snStartedSize = 10
 class to manage threads More...
 

Detailed Description

class to manage threads

OD 2007-01-29 #i73788# An instance of this class takes care of the starting of threads. It assures that not more than <mnStartedSize> threads are started.

Definition at line 47 of file threadmanager.hxx.

Constructor & Destructor Documentation

◆ ThreadManager()

ThreadManager::ThreadManager ( css::uno::Reference< css::util::XJobManager > const &  rThreadJoiner)
explicit

Definition at line 38 of file threadmanager.cxx.

◆ ~ThreadManager()

ThreadManager::~ThreadManager ( )

Definition at line 54 of file threadmanager.cxx.

References maStartedThreads, and maWaitingForStartThreads.

Member Function Documentation

◆ AddThread()

oslInterlockedCount ThreadManager::AddThread ( const ::rtl::Reference< ObservableThread > &  rThread)

◆ DECL_LINK()

ThreadManager::DECL_LINK ( TryToStartNewThread  ,
Timer ,
void   
)

◆ GetThreadListenerWeakRef()

std::weak_ptr< IFinishedThreadListener > ThreadManager::GetThreadListenerWeakRef ( ) const

Definition at line 60 of file threadmanager.cxx.

References mpThreadListener.

Referenced by ThreadListener::ListenToThread().

◆ Init()

void ThreadManager::Init ( void  )

initialization

IMPORTANT NOTE: Needs to be called directly after construction

Definition at line 46 of file threadmanager.cxx.

References LINK, maStartNewThreadIdle, mpThreadListener, Timer::SetInvokeHandler(), and Task::SetPriority().

◆ NotifyAboutFinishedThread()

void ThreadManager::NotifyAboutFinishedThread ( const oslInterlockedCount  nThreadID)

Definition at line 65 of file threadmanager.cxx.

References RemoveThread().

Referenced by ThreadListener::NotifyAboutFinishedThread().

◆ RemoveThread()

void ThreadManager::RemoveThread ( const oslInterlockedCount  nThreadID,
const bool  bThreadFinished = false 
)

◆ ResumeStartingOfThreads()

void ThreadManager::ResumeStartingOfThreads ( )

continues the starting of threads after it has been suspended

Definition at line 227 of file threadmanager.cxx.

References maMutex, maStartedThreads, maStartNewThreadIdle, maWaitingForStartThreads, mbStartingOfThreadsSuspended, snStartedSize, Idle::Start(), and StartWaitingThread().

◆ StartingOfThreadsSuspended()

bool ThreadManager::StartingOfThreadsSuspended ( )
inline

Definition at line 91 of file threadmanager.hxx.

References maMutex, and mbStartingOfThreadsSuspended.

◆ StartThread()

bool ThreadManager::StartThread ( const tThreadData aThreadData)
private

◆ StartWaitingThread()

bool ThreadManager::StartWaitingThread ( )
private

Definition at line 162 of file threadmanager.cxx.

References maWaitingForStartThreads, and StartThread().

Referenced by ResumeStartingOfThreads().

◆ SuspendStartingOfThreads()

void ThreadManager::SuspendStartingOfThreads ( )
inline

suspend the starting of threads

Suspending the starting of further threads is sensible during the destruction of a Writer document.

Definition at line 80 of file threadmanager.hxx.

References maMutex, and mbStartingOfThreadsSuspended.

Member Data Documentation

◆ maMutex

std::mutex ThreadManager::maMutex
private

◆ maStartedThreads

std::deque< tThreadData > ThreadManager::maStartedThreads
private

◆ maStartNewThreadIdle

Idle ThreadManager::maStartNewThreadIdle
private

Definition at line 125 of file threadmanager.hxx.

Referenced by AddThread(), Init(), and ResumeStartingOfThreads().

◆ maWaitingForStartThreads

std::deque< tThreadData > ThreadManager::maWaitingForStartThreads
private

◆ mbStartingOfThreadsSuspended

bool ThreadManager::mbStartingOfThreadsSuspended
private

◆ mnThreadIDCounter

oslInterlockedCount ThreadManager::mnThreadIDCounter
private

Definition at line 120 of file threadmanager.hxx.

Referenced by AddThread().

◆ mpThreadListener

std::shared_ptr< ThreadListener > ThreadManager::mpThreadListener
private

Definition at line 118 of file threadmanager.hxx.

Referenced by AddThread(), GetThreadListenerWeakRef(), and Init().

◆ mrThreadJoiner

css::uno::WeakReference< css::util::XJobManager > ThreadManager::mrThreadJoiner
private

Definition at line 116 of file threadmanager.hxx.

Referenced by RemoveThread(), and StartThread().

◆ snStartedSize

const std::deque< ThreadManager::tThreadData >::size_type ThreadManager::snStartedSize = 10
staticprivate

class to manage threads

#i73788#

Definition at line 112 of file threadmanager.hxx.

Referenced by AddThread(), and ResumeStartingOfThreads().


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