3 const HANDLE handles[2] = {ev, abort.get_abort_event()};
8 PFC_ASSERT( timeout != INFINITE );
12 case WAIT_OBJECT_0 + 1:
13 throw exception_aborted();
23 while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
24 DispatchMessage(&msg);
30 const HANDLE handles[2] = {ev, abort.get_abort_event()};
33 const DWORD status = MsgWaitForMultipleObjects(2, handles, FALSE, INFINITE, QS_ALLINPUT);
36 PFC_ASSERT(!
"How did we get here?");
40 case WAIT_OBJECT_0 + 1:
41 throw exception_aborted();
42 case WAIT_OBJECT_0 + 2:
55 handles[0] = abort.get_abort_event();
59 const DWORD status = MsgWaitForMultipleObjects(handles.
get_count(), handles.
get_ptr(), FALSE, INFINITE, QS_ALLINPUT);
62 PFC_ASSERT(!
"How did we get here?");
65 throw exception_aborted();
71 if (index == evCount) {
73 }
else if (index < evCount) {
84 PFC_ASSERT( timeout != INFINITE );
85 const DWORD entry = GetTickCount();
86 const HANDLE handles[1] = {abort.get_abort_event()};
88 const DWORD done = GetTickCount() - entry;
89 if (done >= timeout)
return;
91 const DWORD status = MsgWaitForMultipleObjects(1, handles, FALSE, timeout - done, QS_ALLINPUT);
96 throw exception_aborted();
97 case WAIT_OBJECT_0 + 1:
106 PFC_ASSERT( timeout != INFINITE );
107 const DWORD entry = GetTickCount();
108 const HANDLE handles[2] = {ev, abort.get_abort_event()};
110 const DWORD done = GetTickCount() - entry;
111 if (done >= timeout)
return false;
113 const DWORD status = MsgWaitForMultipleObjects(2, handles, FALSE, timeout - done, QS_ALLINPUT);
119 case WAIT_OBJECT_0 + 1:
120 throw exception_aborted();
121 case WAIT_OBJECT_0 + 2:
132 template<
typename TWhat>
137 template<
typename TSource>
void Add(
const TSource & source) {
153 template<
typename TDestination>
void _Get(TDestination & out) {
156 FB2K_DYNAMIC_ASSERT( iter.
is_valid() );
167 template<
typename TBase,
bool processMsgs = false>
188 }
catch(exception_aborted
const & e) {
189 m_status = fail_abort; m_statusMsg = e.what();
190 }
catch(exception_io_data
const & e) {
191 m_status = fail_io_data; m_statusMsg = e.what();
192 }
catch(exception_io
const & e) {
193 m_status = fail_io; m_statusMsg = e.what();
195 m_status =
fail; m_statusMsg = e.what();
197 SetEvent(m_completionEvent);
204 throw exception_io(m_statusMsg);
206 throw exception_io_data(m_statusMsg);
208 throw exception_aborted();
224 m_completionEvent.create(
true,
false);
230 m_threadAbort.abort();
231 this->WaitTillThreadDone();
236 m_completionEvent.set_state(
false);
240 m_completionEvent.wait_for(-1);
247 TRACK_CALL_TEXT(
"CSingleThreadWrapper entry");
252 if (processMsgs) m_commands.Get_MsgLoop(cmd, m_threadAbort);
253 else m_commands.Get(cmd, m_threadAbort);
254 cmd->execute(instance);
CObjectQueue< command_ptr > m_commands
DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE *lpHandles, BOOL bWaitAll, DWORD dwMilliseconds)
const t_item * get_ptr() const
PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL()
void add_item(const t_source &p_source)
static void SleepAbortable_MsgLoop(abort_callback &abort, DWORD timeout)
void Get(TDestination &out, abort_callback &abort)
void Add(const TSource &source)
static void fail(completion_notify_ptr p_notify)
abort_callback_impl m_threadAbort
pfc::chain_list_v2_t< TWhat > m_content
typedef HANDLE(WINAPI *pPowerCreateRequest_t)(__in void *Context)
pfc::rcptr_t< command > command_ptr
void remove(const_iterator const &p_iter)
void invokeCommand(command_ptr cmd, abort_callback &abort)
void set_size(t_size p_size)
void _Get(TDestination &out)
static bool WaitAbortable(HANDLE ev, abort_callback &abort, DWORD timeout=INFINITE)
static t_size MultiWaitAbortable_MsgLoop(const HANDLE *ev, t_size evCount, abort_callback &abort)
win32_event m_completionEvent
static void WaitAbortable_MsgLoop(HANDLE ev, abort_callback &abort)
virtual void executeImpl(TBase &)
void memcpy_t(t_dst *p_dst, const t_src *p_src, t_size p_count)
IMPORTANT: all classes derived from CVerySimpleThread must call WaitTillThreadDone() in their destruc...
void create(bool p_manualreset, bool p_initialstate)
PFC_NORETURN void SHARED_EXPORT uBugCheck()
static void ProcessPendingMessages()
void Get_MsgLoop(TDestination &out, abort_callback &abort)
void set_state(bool p_state)