foobar2000 SDK  2015-01-14
abort_callback.cpp
Go to the documentation of this file.
1 #include "foobar2000.h"
2 
3 void abort_callback::check() const {
4  if (is_aborting()) throw exception_aborted();
5 }
6 
7 void abort_callback::sleep(double p_timeout_seconds) const {
8  if (!sleep_ex(p_timeout_seconds)) throw exception_aborted();
9 }
10 
11 bool abort_callback::sleep_ex(double p_timeout_seconds) const {
12  // return true IF NOT SET (timeout), false if set
13  return !pfc::event::g_wait_for(get_abort_event(),p_timeout_seconds);
14 }
15 
16 bool abort_callback::waitForEvent( pfc::eventHandle_t evtHandle, double timeOut ) {
17  int status = pfc::event::g_twoEventWait( this->get_abort_event(), evtHandle, timeOut );
18  switch(status) {
19  case 1: throw exception_aborted();
20  case 2: return true;
21  case 0: return false;
22  default: uBugCheck();
23  }
24 }
HANDLE eventHandle_t
Definition: event.h:4
static int g_twoEventWait(win32_event &ev1, win32_event &ev2, double timeout)
static bool g_wait_for(HANDLE p_event, double p_timeout_seconds)
Returns true when signaled, false on timeout.
PFC_NORETURN void SHARED_EXPORT uBugCheck()