foobar2000 SDK  2015-08-03
Public Member Functions | Protected Member Functions
foobar2000_io::abort_callbackabstract

#include <abort_callback.h>

+ Inheritance diagram for foobar2000_io::abort_callback:

Public Member Functions

void check () const
 
void check_e () const
 
virtual abort_callback_event get_abort_event () const =0
 
abort_callback_event get_handle () const
 
virtual bool is_aborting () const =0
 
bool is_set () const
 
void sleep (double p_timeout_seconds) const
 
bool sleep_ex (double p_timeout_seconds) const
 
bool waitForEvent (pfc::eventHandle_t evtHandle, double timeOut)
 
bool waitForEvent (pfc::event &evt, double timeOut)
 

Protected Member Functions

 abort_callback ()
 
 ~abort_callback ()
 

Detailed Description

This class is used to signal underlying worker code whether user has decided to abort a potentially time-consuming operation.
It is commonly required by all filesystem related or decoding-related operations.
Code that receives an abort_callback object should periodically check it and abort any operations being performed if it is signaled, typically throwing exception_aborted.
See abort_callback_impl for an implementation.

Definition at line 17 of file abort_callback.h.

Constructor & Destructor Documentation

foobar2000_io::abort_callback::abort_callback ( )
inlineprotected

Definition at line 46 of file abort_callback.h.

46 {}
foobar2000_io::abort_callback::~abort_callback ( )
inlineprotected

Definition at line 47 of file abort_callback.h.

47 {}

Member Function Documentation

void abort_callback::check ( ) const

Checks if user has requested the operation to be aborted, and throws exception_aborted if so.

Definition at line 3 of file abort_callback.cpp.

3  {
4  if (is_aborting()) throw exception_aborted();
5 }
virtual bool is_aborting() const =0
Returns whether user has requested the operation to be aborted.
void foobar2000_io::abort_callback::check_e ( ) const
inline

For compatibility with old code. Do not call.

Definition at line 35 of file abort_callback.h.

35 {check();}
void check() const
Checks if user has requested the operation to be aborted, and throws exception_aborted if so...
virtual abort_callback_event foobar2000_io::abort_callback::get_abort_event ( ) const
pure virtual

Retrieves event object that can be used with some OS calls. The even object becomes signaled when abort is triggered. On win32, this is equivalent to win32 event handle (see: CreateEvent).
You must not close this handle or call any methods that change this handle's state (SetEvent() or ResetEvent()), you can only wait for it.

Implemented in foobar2000_io::abort_callback_dummy, and foobar2000_io::abort_callback_impl.

abort_callback_event foobar2000_io::abort_callback::get_handle ( ) const
inline

Definition at line 29 of file abort_callback.h.

29 {return get_abort_event();}
virtual abort_callback_event get_abort_event() const =0
Retrieves event object that can be used with some OS calls. The even object becomes signaled when abo...
virtual bool foobar2000_io::abort_callback::is_aborting ( ) const
pure virtual

Returns whether user has requested the operation to be aborted.

Implemented in foobar2000_io::abort_callback_dummy, and foobar2000_io::abort_callback_impl.

bool foobar2000_io::abort_callback::is_set ( ) const
inline

Definition at line 23 of file abort_callback.h.

23 {return is_aborting();}
virtual bool is_aborting() const =0
Returns whether user has requested the operation to be aborted.
void abort_callback::sleep ( double  p_timeout_seconds) const

Sleeps p_timeout_seconds or less when aborted, throws exception_aborted on abort.

Definition at line 7 of file abort_callback.cpp.

7  {
8  if (!sleep_ex(p_timeout_seconds)) throw exception_aborted();
9 }
bool sleep_ex(double p_timeout_seconds) const
Sleeps p_timeout_seconds or less when aborted, returns true when execution should continue...
bool abort_callback::sleep_ex ( double  p_timeout_seconds) const

Sleeps p_timeout_seconds or less when aborted, returns true when execution should continue, false when not.

Definition at line 11 of file abort_callback.cpp.

11  {
12  // return true IF NOT SET (timeout), false if set
13  return !pfc::event::g_wait_for(get_abort_event(),p_timeout_seconds);
14 }
virtual abort_callback_event get_abort_event() const =0
Retrieves event object that can be used with some OS calls. The even object becomes signaled when abo...
static bool g_wait_for(HANDLE p_event, double p_timeout_seconds)
Returns true when signaled, false on timeout.
bool abort_callback::waitForEvent ( pfc::eventHandle_t  evtHandle,
double  timeOut 
)

Definition at line 16 of file abort_callback.cpp.

16  {
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 }
virtual abort_callback_event get_abort_event() const =0
Retrieves event object that can be used with some OS calls. The even object becomes signaled when abo...
static int g_twoEventWait(win32_event &ev1, win32_event &ev2, double timeout)
PFC_NORETURN void SHARED_EXPORT uBugCheck()
bool foobar2000_io::abort_callback::waitForEvent ( pfc::event evt,
double  timeOut 
)
inline

Definition at line 44 of file abort_callback.h.

44 {return waitForEvent( evt.get_handle(), timeOut ); }
bool waitForEvent(pfc::eventHandle_t evtHandle, double timeOut)
HANDLE get_handle() const
Definition: event.h:10

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