Public Types | |
typedef unsigned long | DataLength |
enum | Flags { MarshalWritesToThreadPool = 0x01, ExecuteWritesOnCallingThread = 0x02, MarshallingFlagsMask = 0x0F, NoBuffering = 0x10, WriteThrough = 0x20, PreExtendFile = 0x40, BufferingFlagsMask = 0xF0 } |
Public Member Functions | |
CAsyncFileWriterEx (const JetByteTools::Core::_tstring &filename, Callback &callback, IIOPool &pool, IAllocateBuffers &allocator, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter) | |
Write to the specified file asynchronously using overlapped I/O via the threads in the supplied IIOPool using buffers provided by the IAllocateBuffers instance and push any errors that occur to the CAsyncFileWriter::Callback interface. | |
CAsyncFileWriterEx (const JetByteTools::Core::_tstring &filename, Callback &callback, IIOPool &pool, IMonitorAsyncFileWriter &monitor, IAllocateBuffers &allocator, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter) | |
Write to the specified file asynchronously using overlapped I/O via the threads in the supplied IIOPool, monitor write progress using the supplied monitor and use buffers provided by the IAllocateBuffers instance and push any errors that occur to the CAsyncFileWriter::Callback interface. | |
CAsyncFileWriterEx (const JetByteTools::Core::_tstring &filename, JetByteTools::Win32::CSmartHandle &handle, Callback &callback, IIOPool &pool, IAllocateBuffers &allocator, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter) | |
Write to the specified file asynchronously using overlapped I/O via the threads in the supplied IIOPool using buffers provided by the IAllocateBuffers instance and push any errors that occur to the CAsyncFileWriter::Callback interface. | |
CAsyncFileWriterEx (const JetByteTools::Core::_tstring &filename, JetByteTools::Win32::CSmartHandle &handle, Callback &callback, IIOPool &pool, IMonitorAsyncFileWriter &monitor, IAllocateBuffers &allocator, ILimitPendingWrites &writeLimiter=CPendingWriteLimiter::NoLimitLimiter) | |
Write to the specified file asynchronously using overlapped I/O via the threads in the supplied IIOPool, monitor write progress using the supplied monitor and use buffers provided by the IAllocateBuffers instance and push any errors that occur to the CAsyncFileWriter::Callback interface. | |
CAsyncFileWriterEx (const CAsyncFileWriterEx &rhs) | |
~CAsyncFileWriterEx () override | |
CAsyncFileWriterEx & | operator= (const CAsyncFileWriterEx &rhs) |
void | Write (const BYTE *pData, DataLength dataLength) |
void | Write (const JetByteTools::Core::Data *pData, DataLength count) |
Write the data to the file. | |
bool | PerformWritesOnThisThread () const |
Returns true if writes are issued directly from the calling thread and false if they are marshalled to the thread pool. | |
void | Write (CSmartBuffer &buffer) |
Write the contents of the IBuffer to the file. | |
void | Close () |
Close the file. | |
void | NotifyOnNoWrites (bool notifyNowIfNoWritesPending=true) |
Causes the file writer to call Callback::OnLastWrite() when the count of pending writes reaches zero. If you call this and pass true for notifyNowIfNoWritesPending and there currently no outstanding writes then the callback is called immediately. Note: You may get multiple calls to OnLastWrite() for a single 'last write' completion as we don't bother to guard against the race condition between this call and the actual write completions. It's best to call this when you would otherwise call Wait(), i.e. after the last write that you intend to issue on this file writer. | |
const JetByteTools::Core::_tstring & | GetFilenameIfKnown () const |
Returns the name of the file if the file writer was created from a file name and an empty string if the file writer was created from a file handle. | |
__int64 | GetFileSize () const |
Returns the current size of the file in bytes. | |
HANDLE | GetWaitHandle () const override |
void | Wait () const override |
bool | Wait (Milliseconds timeout) const override |
Static Public Member Functions | |
static JetByteTools::Win32::CSmartHandle | OpenSuitableFile (const JetByteTools::Core::_tstring &filename, long flags=0) |
static JetByteTools::Win32::CSmartHandle | CreateSuitableFile (const JetByteTools::Core::_tstring &filename, long flags=0) |
static JetByteTools::Win32::CSmartHandle | TryCreateSuitableFile (const JetByteTools::Core::_tstring &filename, long flags=0) |
Static Public Attributes | |
static const LARGE_INTEGER | DoNotPreExtendFile |
Used to specify to the constructors that you do not wish to extend the size of the file during construction and then trim it to the correct size when all data has been written. Note that file systems extend files synchronously (See Richter 2008). By specifying a file size during construction we can extend the size of the file and allow the actual data writes to occur asynchronously. | |
Protected Member Functions | |
void | GetNextWriteOffset (LARGE_INTEGER &offset, DataLength dataLength) |
void | RequestWrite (CSmartBuffer &buffer) |
typedef unsigned long DataLength |
Reimplemented from CAsyncFileWriter.
enum Flags [inherited] |
CAsyncFileWriterEx | ( | const JetByteTools::Core::_tstring & | filename, | |
Callback & | callback, | |||
IIOPool & | pool, | |||
IAllocateBuffers & | allocator, | |||
ILimitPendingWrites & | writeLimiter = CPendingWriteLimiter::NoLimitLimiter | |||
) |
Write to the specified file asynchronously using overlapped I/O via the threads in the supplied IIOPool using buffers provided by the IAllocateBuffers instance and push any errors that occur to the CAsyncFileWriter::Callback interface.
CAsyncFileWriterEx | ( | const JetByteTools::Core::_tstring & | filename, | |
Callback & | callback, | |||
IIOPool & | pool, | |||
IMonitorAsyncFileWriter & | monitor, | |||
IAllocateBuffers & | allocator, | |||
ILimitPendingWrites & | writeLimiter = CPendingWriteLimiter::NoLimitLimiter | |||
) |
Write to the specified file asynchronously using overlapped I/O via the threads in the supplied IIOPool, monitor write progress using the supplied monitor and use buffers provided by the IAllocateBuffers instance and push any errors that occur to the CAsyncFileWriter::Callback interface.
CAsyncFileWriterEx | ( | const JetByteTools::Core::_tstring & | filename, | |
JetByteTools::Win32::CSmartHandle & | handle, | |||
Callback & | callback, | |||
IIOPool & | pool, | |||
IAllocateBuffers & | allocator, | |||
ILimitPendingWrites & | writeLimiter = CPendingWriteLimiter::NoLimitLimiter | |||
) |
Write to the specified file asynchronously using overlapped I/O via the threads in the supplied IIOPool using buffers provided by the IAllocateBuffers instance and push any errors that occur to the CAsyncFileWriter::Callback interface.
CAsyncFileWriterEx | ( | const JetByteTools::Core::_tstring & | filename, | |
JetByteTools::Win32::CSmartHandle & | handle, | |||
Callback & | callback, | |||
IIOPool & | pool, | |||
IMonitorAsyncFileWriter & | monitor, | |||
IAllocateBuffers & | allocator, | |||
ILimitPendingWrites & | writeLimiter = CPendingWriteLimiter::NoLimitLimiter | |||
) |
Write to the specified file asynchronously using overlapped I/O via the threads in the supplied IIOPool, monitor write progress using the supplied monitor and use buffers provided by the IAllocateBuffers instance and push any errors that occur to the CAsyncFileWriter::Callback interface.
CAsyncFileWriterEx | ( | const CAsyncFileWriterEx & | rhs | ) |
~CAsyncFileWriterEx | ( | ) | [override] |
CAsyncFileWriterEx& operator= | ( | const CAsyncFileWriterEx & | rhs | ) |
void Write | ( | const BYTE * | pData, | |
DataLength | dataLength | |||
) |
void Write | ( | const JetByteTools::Core::Data * | pData, | |
DataLength | count | |||
) |
Write the data to the file.
static JetByteTools::Win32::CSmartHandle OpenSuitableFile | ( | const JetByteTools::Core::_tstring & | filename, | |
long | flags = 0 | |||
) | [static, inherited] |
static JetByteTools::Win32::CSmartHandle CreateSuitableFile | ( | const JetByteTools::Core::_tstring & | filename, | |
long | flags = 0 | |||
) | [static, inherited] |
static JetByteTools::Win32::CSmartHandle TryCreateSuitableFile | ( | const JetByteTools::Core::_tstring & | filename, | |
long | flags = 0 | |||
) | [static, inherited] |
bool PerformWritesOnThisThread | ( | ) | const [inherited] |
Returns true if writes are issued directly from the calling thread and false if they are marshalled to the thread pool.
void Write | ( | CSmartBuffer & | buffer | ) | [inherited] |
Write the contents of the IBuffer to the file.
void Close | ( | ) | [inherited] |
Close the file.
void NotifyOnNoWrites | ( | bool | notifyNowIfNoWritesPending = true |
) | [inherited] |
Causes the file writer to call Callback::OnLastWrite() when the count of pending writes reaches zero. If you call this and pass true for notifyNowIfNoWritesPending and there currently no outstanding writes then the callback is called immediately. Note: You may get multiple calls to OnLastWrite() for a single 'last write' completion as we don't bother to guard against the race condition between this call and the actual write completions. It's best to call this when you would otherwise call Wait(), i.e. after the last write that you intend to issue on this file writer.
const _tstring & GetFilenameIfKnown | ( | ) | const [inherited] |
Returns the name of the file if the file writer was created from a file name and an empty string if the file writer was created from a file handle.
__int64 GetFileSize | ( | ) | const [inherited] |
Returns the current size of the file in bytes.
HANDLE GetWaitHandle | ( | ) | const [override, inherited] |
void Wait | ( | ) | const [override, inherited] |
bool Wait | ( | Milliseconds | timeout | ) | const [override, inherited] |
void GetNextWriteOffset | ( | LARGE_INTEGER & | offset, | |
DataLength | dataLength | |||
) | [protected, inherited] |
void RequestWrite | ( | CSmartBuffer & | buffer | ) | [protected, inherited] |
const LARGE_INTEGER DoNotPreExtendFile [static, inherited] |
Used to specify to the constructors that you do not wish to extend the size of the file during construction and then trim it to the correct size when all data has been written. Note that file systems extend files synchronously (See Richter 2008). By specifying a file size during construction we can extend the size of the file and allow the actual data writes to occur asynchronously.