#include <ProcessUtils.h>
|
| PipeIO (HANDLE handle, HANDLE hEvent, bool processMessages, DWORD timeOut=INFINITE) |
|
| ~PipeIO () |
|
| PFC_DECLARE_EXCEPTION (timeout, exception_io,"Timeout") |
|
size_t | read (void *p_buffer, size_t p_bytes, abort_callback &abort) |
|
size_t | readPass (void *p_buffer, size_t p_bytes, abort_callback &abort) |
|
void | write (const void *p_buffer, size_t p_bytes, abort_callback &abort) |
|
Definition at line 4 of file ProcessUtils.h.
ProcessUtils::PipeIO::PipeIO |
( |
HANDLE |
handle, |
|
|
HANDLE |
hEvent, |
|
|
bool |
processMessages, |
|
|
DWORD |
timeOut = INFINITE |
|
) |
| |
|
inline |
ProcessUtils::PipeIO::~PipeIO |
( |
| ) |
|
|
inline |
void ProcessUtils::PipeIO::_cancel |
( |
OVERLAPPED & |
ol | ) |
|
|
inlineprivate |
DWORD ProcessUtils::PipeIO::myWait |
( |
DWORD |
count, |
|
|
const HANDLE * |
handles |
|
) |
| |
|
inlineprivate |
Definition at line 101 of file ProcessUtils.h.
104 DWORD state = MsgWaitForMultipleObjects(count, handles, FALSE,
m_timeOut, QS_ALLINPUT);
105 if (state == WAIT_OBJECT_0 + count) {
DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE *lpHandles, BOOL bWaitAll, DWORD dwMilliseconds)
const bool m_processMessages
static void ProcessPendingMessages()
ProcessUtils::PipeIO::PFC_DECLARE_EXCEPTION |
( |
timeout |
, |
|
|
exception_io |
, |
|
|
"Timeout" |
|
|
) |
| |
static void ProcessUtils::PipeIO::ProcessPendingMessages |
( |
| ) |
|
|
inlinestaticprivate |
Definition at line 122 of file ProcessUtils.h.
124 while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
size_t ProcessUtils::PipeIO::read |
( |
void * |
p_buffer, |
|
|
size_t |
p_bytes, |
|
|
abort_callback & |
abort |
|
) |
| |
|
inline |
Definition at line 46 of file ProcessUtils.h.
47 uint8_t * ptr = (uint8_t*) p_buffer;
49 while(done < p_bytes) {
51 size_t delta =
readPass(ptr + done, p_bytes - done, abort);
52 if (delta == 0)
break;
size_t readPass(void *p_buffer, size_t p_bytes, abort_callback &abort)
size_t ProcessUtils::PipeIO::readPass |
( |
void * |
p_buffer, |
|
|
size_t |
p_bytes, |
|
|
abort_callback & |
abort |
|
) |
| |
|
inline |
Definition at line 57 of file ProcessUtils.h.
58 if (p_bytes == 0)
return 0;
63 SetLastError(NO_ERROR);
64 if (ReadFile(
m_handle, p_buffer, pfc::downcast_guarded<DWORD>(p_bytes), &bytesDone, &ol)) {
70 const DWORD code = GetLastError();
72 case ERROR_HANDLE_EOF:
74 case ERROR_IO_PENDING:
82 SetLastError(NO_ERROR);
83 DWORD state =
myWait(_countof(handles), handles);
84 if (state == WAIT_OBJECT_0) {
85 SetLastError(NO_ERROR);
86 if (!GetOverlappedResult(
m_handle,&ol,&bytesDone,TRUE)) {
87 const DWORD code = GetLastError();
88 if (code == ERROR_HANDLE_EOF) bytesDone = 0;
PFC_NORETURN void exception_io_from_win32(DWORD p_code)
typedef HANDLE(WINAPI *pPowerCreateRequest_t)(__in void *Context)
void _cancel(OVERLAPPED &ol)
DWORD myWait(DWORD count, const HANDLE *handles)
void ProcessUtils::PipeIO::write |
( |
const void * |
p_buffer, |
|
|
size_t |
p_bytes, |
|
|
abort_callback & |
abort |
|
) |
| |
|
inline |
Definition at line 12 of file ProcessUtils.h.
13 if (p_bytes == 0)
return;
18 SetLastError(NO_ERROR);
19 if (WriteFile(
m_handle, p_buffer, pfc::downcast_guarded<DWORD>(p_bytes), &bytesWritten, &ol)) {
21 if (bytesWritten != p_bytes)
throw exception_io();
26 const DWORD code = GetLastError();
30 SetLastError(NO_ERROR);
31 DWORD state =
myWait(_countof(handles), handles);
32 if (state == WAIT_OBJECT_0) {
34 WIN32_IO_OP( GetOverlappedResult(
m_handle,&ol,&bytesWritten,TRUE) );
39 if (bytesWritten != p_bytes)
throw exception_io();
PFC_NORETURN void exception_io_from_win32(DWORD p_code)
typedef HANDLE(WINAPI *pPowerCreateRequest_t)(__in void *Context)
void _cancel(OVERLAPPED &ol)
DWORD myWait(DWORD count, const HANDLE *handles)
HANDLE ProcessUtils::PipeIO::m_event |
|
private |
HANDLE ProcessUtils::PipeIO::m_handle |
|
private |
const bool ProcessUtils::PipeIO::m_processMessages |
|
private |
const DWORD ProcessUtils::PipeIO::m_timeOut |
|
private |
The documentation for this class was generated from the following file: