foobar2000 SDK  2015-08-03
Data Structures | Protected Types | Protected Member Functions | Private Types | Private Member Functions | Private Attributes
ThreadUtils::CSingleThreadWrapper< TBase, processMsgs >

#include <ThreadUtils.h>

+ Inheritance diagram for ThreadUtils::CSingleThreadWrapper< TBase, processMsgs >:

Data Structures

class  command
 

Protected Types

typedef pfc::rcptr_t< commandcommand_ptr
 

Protected Member Functions

 CSingleThreadWrapper ()
 
 ~CSingleThreadWrapper ()
 
void invokeCommand (command_ptr cmd, abort_callback &abort)
 
- Protected Member Functions inherited from CVerySimpleThread
 CVerySimpleThread ()
 
bool IsThreadActive () const
 
void StartThread (int priority)
 
void StartThread ()
 
void WaitTillThreadDone ()
 

Private Types

enum  status {
  success, fail, fail_io, fail_io_data,
  fail_abort
}
 

Private Member Functions

void ThreadProc ()
 

Private Attributes

CObjectQueue< command_ptrm_commands
 
win32_event m_completionEvent
 
abort_callback_impl m_threadAbort
 

Detailed Description

template<typename TBase, bool processMsgs = false>
class ThreadUtils::CSingleThreadWrapper< TBase, processMsgs >

Definition at line 168 of file ThreadUtils.h.

Member Typedef Documentation

template<typename TBase , bool processMsgs = false>
typedef pfc::rcptr_t<command> ThreadUtils::CSingleThreadWrapper< TBase, processMsgs >::command_ptr
protected

Definition at line 221 of file ThreadUtils.h.

Member Enumeration Documentation

template<typename TBase , bool processMsgs = false>
enum ThreadUtils::CSingleThreadWrapper::status
private

Constructor & Destructor Documentation

template<typename TBase , bool processMsgs = false>
ThreadUtils::CSingleThreadWrapper< TBase, processMsgs >::CSingleThreadWrapper ( )
inlineprotected

Definition at line 223 of file ThreadUtils.h.

223  {
224  m_completionEvent.create(true,false);
225  this->StartThread();
226  //start();
227  }
void create(bool p_manualreset, bool p_initialstate)
template<typename TBase , bool processMsgs = false>
ThreadUtils::CSingleThreadWrapper< TBase, processMsgs >::~CSingleThreadWrapper ( )
inlineprotected

Definition at line 229 of file ThreadUtils.h.

229  {
230  m_threadAbort.abort();
231  this->WaitTillThreadDone();
232  }
void WaitTillThreadDone()
Definition: fb2k_threads.h:18
abort_callback_impl m_threadAbort
Definition: ThreadUtils.h:261

Member Function Documentation

template<typename TBase , bool processMsgs = false>
void ThreadUtils::CSingleThreadWrapper< TBase, processMsgs >::invokeCommand ( command_ptr  cmd,
abort_callback abort 
)
inlineprotected

Definition at line 234 of file ThreadUtils.h.

234  {
235  abort.check();
237  pfc::vartoggle_t<abort_callback*> abortToggle(cmd->m_abort, &abort);
238  pfc::vartoggle_t<HANDLE> eventToggle(cmd->m_completionEvent, m_completionEvent.get() );
239  m_commands.Add(cmd);
241  //WaitAbortable(m_completionEvent.get(), abort);
242  cmd->rethrow();
243  }
CObjectQueue< command_ptr > m_commands
Definition: ThreadUtils.h:260
HANDLE get() const
Definition: win-objects.h:131
bool wait_for(double p_timeout_seconds)
Returns true when signaled, false on timeout.
Definition: win-objects.h:139
void set_state(bool p_state)
template<typename TBase , bool processMsgs = false>
void ThreadUtils::CSingleThreadWrapper< TBase, processMsgs >::ThreadProc ( )
inlineprivatevirtual

Implements CVerySimpleThread.

Definition at line 246 of file ThreadUtils.h.

246  {
247  TRACK_CALL_TEXT("CSingleThreadWrapper entry");
248  try {
249  TBase instance;
250  for(;;) {
251  command_ptr cmd;
252  if (processMsgs) m_commands.Get_MsgLoop(cmd, m_threadAbort);
253  else m_commands.Get(cmd, m_threadAbort);
254  cmd->execute(instance);
255  }
256  } catch(...) {}
257  if (processMsgs) ProcessPendingMessages();
258  }
CObjectQueue< command_ptr > m_commands
Definition: ThreadUtils.h:260
abort_callback_impl m_threadAbort
Definition: ThreadUtils.h:261
pfc::rcptr_t< command > command_ptr
Definition: ThreadUtils.h:221
static void ProcessPendingMessages()
Definition: ThreadUtils.h:21

Field Documentation

template<typename TBase , bool processMsgs = false>
CObjectQueue<command_ptr> ThreadUtils::CSingleThreadWrapper< TBase, processMsgs >::m_commands
private

Definition at line 260 of file ThreadUtils.h.

template<typename TBase , bool processMsgs = false>
win32_event ThreadUtils::CSingleThreadWrapper< TBase, processMsgs >::m_completionEvent
private

Definition at line 259 of file ThreadUtils.h.

template<typename TBase , bool processMsgs = false>
abort_callback_impl ThreadUtils::CSingleThreadWrapper< TBase, processMsgs >::m_threadAbort
private

Definition at line 261 of file ThreadUtils.h.


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