public:
CAsyncIo(CAsyncStream *pStream);
~CAsyncIo();
// open the file
HRESULT Open(LPCTSTR pName);
// ready for async activity - call this before
// calling Request
HRESULT AsyncActive(void);
// call this when no more async activity will happen before
// the next AsyncActive call
HRESULT AsyncInactive(void);
// queue a requested read. must be aligned.
HRESULT Request(
LONGLONG llPos,
LONG lLength,
BOOL bAligned,
BYTE* pBuffer,
LPVOID pContext,
DWORD dwUser);
// wait for the next read to complete
HRESULT WaitForNext(
DWORD dwTimeout,
LPVOID *ppContext,
DWORD * pdwUser,
LONG * pcbActual);
// perform a read of an already aligned buffer
HRESULT SyncReadAligned(
LONGLONG llPos,
LONG lLength,
BYTE* pBuffer,
LONG* pcbActual,
PVOID pvContext);
// perform a synchronous read. will be buffered
// if not aligned.
HRESULT SyncRead(
LONGLONG llPos,
LONG lLength,
BYTE* pBuffer);
// return length
HRESULT Length(LONGLONG *pllTotal, LONGLONG* pllAvailable);
// all Reader positions, read lengths and memory locations must
// be aligned to this.
HRESULT Alignment(LONG* pl);
HRESULT BeginFlush();
HRESULT EndFlush();
LONG Alignment()
{
return m_pStream->Alignment();
};
BOOL IsAligned(LONG l) {
if ((l & (Alignment() -1)) == 0) {
return TRUE;
} else {
return FALSE;
}
};
BOOL IsAligned(LONGLONG ll) {
return IsAligned( (LONG) (ll & 0xffffffff));
};
// Accessor
HANDLE StopEvent() const { return m_evDone; }
};
#endif // __ASYNCIO_H__