The C++ framework for developing highly scalable, high performance servers on Windows platforms.

JetByteTools::IO Namespace Reference


Classes

class  CAsyncFileLog
 A class that implements JetByteTools::Core::ILogMessages to provide an asynchronous file log that uses overlapped I/O to perform writes to the log file. This class allows you to change the name of the log file after creation but this functionality should be externally synchronised with any use of the various LogMessage() calls and any calls on the IWaitable interface to ensure that SetLogName() is never called concurrently to one of the other calls. The reason that we require YOU to do this synchronisation work is that when used carefully (i.e. SetLogName() is never called when the class is being used by multiple threads) then there is no need to synchronise the calls to LogMessage(). More...
class  CAsyncFileReader
 A class that implements IHandler to provide an asynchronous file reader that uses overlapped I/O to perform reads from the file. Data read from the file is provided in a 'push fashion' via the CAsyncFileReader::Callback interface. More...
class  CAsyncFileWriter
 A class that implements IHandler to provide an asynchronous file writer that uses overlapped I/O to perform writes to the file. Any errors that occur during the asynchronous file writes are reported via the CAsyncFileWriter::Callback interface. More...
class  CAsyncFileWriterEx
 A class that implements IHandler to provide an asynchronous file writer that uses overlapped I/O to perform writes to the file. Any errors that occur during the asynchronous file writes are reported via the CAsyncFileWriter::Callback interface. More...
class  CBuffer
 An implementation of the IBuffer interface which includes its own custom new and delete functionality so that the memory for the buffer and the memory for the rest of the class are allocated as a single block of memory. Note that the 'user data' is also allocated as part of the main buffer memory and the class knows how to access the various memory areas correctly. Note that the buffers may be allocated using VirtualAlloc() to align the memory on page boundaries; in this case, it's best to create buffers with a size that is a multiple of the system's page size less the size of the buffer object, see CBufferAllocator for more details. More...
class  CBufferAllocator
 An implementation of IAllocateBuffers which pools buffer instances for later reuse. More...
class  CBufferBasedBufferAllocator
class  CBufferChain
class  CBufferChainStoresNulls
class  CBufferFacadeOnRawMemory
class  CBufferHandle
 An implementation of IBuffer that provides a separate WSABUF for another implementation of IBuffer. This is used to broadcast the contents of an IBuffer to multiple receivers without needing to copy the data in the buffer. Each receiver has a CBufferHandle allocated which is attached to the IBuffer that contains the data that needs to be broadcast. When the final send completes the references held by the CBufferHandle objects on the IBuffer will fall to 0 and the buffer will be released. More...
class  CBufferHandleAllocator
 An implementation of IAllocateBufferHandles which pools buffer handle instances for later reuse. More...
class  TBufferPool
class  CBufferProcessor
class  CBufferRingBuffer
class  CCustomPoolBufferAllocator
class  CCustomPoolSmartBuffer
class  CFileInputStream
 An object that implements IInputStream on a file. More...
class  CFileOutputStream
 An object that implements ICloseableOutputStream on a file. More...
class  CFixedFileHeaderRotatingAsyncFileLog
 A class that implements JetByteTools::ILogMessages to provide an asynchronous file log that uses overlapped I/O to perform writes to the log file. The log can be set to automatically rotate (i.e. create a new log file) after a set period of time or when the file grows to a particular size. More...
class  IAddBuffersToPool
class  IAllocatableBuffer
class  IAllocateBuffer
class  IAllocateBufferHandles
 An interface to a class that allocates instances of CBufferHandle which can be attached to an instance of an IBuffer. More...
class  IAllocateBuffers
 An interface to a class that allocates instances of IBuffer of a fixed size. Each instance of IBuffer has opaque user data associated with it and so this allocator derives from IProvideUserData to allow the user to request user data "slots" from the allocator; you must request all of your slots before calling Allocate() for the first time. More...
class  IAssociateDeviceWithIOSubSystem
class  IAsyncIOStream
 An interface onto an asynchrnonous I/O stream. Calls to Write() are not guaranteed to have completed when the call returns and calls to Read() simply request that a Read() happens and do not, in any way, result in incoming data being placed in the provided buffer before the call returns. Objects that implement this interface must provide another way to provide the caller with the data that is read from the stream when the read actually completes. More...
class  IBufferIntrusiveCollectionAdapterSequenceNumberKeyAccessor
class  IBufferBase
 An interface to a I/O buffer (with a partially refactored name!). Initially IBuffer and IBufferBase was one class, it was split to make it easier to mock and in an attempt to remove some of the socket stuff. Classes that implement this interface represent a byte buffer that can be used for overlapped I/O and that consist of a contiguous array of bytes and an insertion point which moves along the buffer as data is added to it. More work needs to be done. More...
class  IBufferChain
class  IBufferProcessor
class  ICloseableOutputStream
 An extension to IOutputStream that allows the user to call Close() on it. More...
class  IDispatchToWorkerThread
class  IHandleFileCreationFailure
class  IHandler
 An interface that represents code that handles operations on I/O buffers. More...
class  IInputStream
 An interface to an input stream (which may be sync or async). More...
class  IIOPool
 An interface to an I/O thread pool (usually based on an I/O completion port) that can have operations on buffers and handlers dispatched to it (either directly or as a result of an I/O completion packet being generated by some asynchronous I/O event) and that handles these events on one of the threads in the pool. More...
class  IIOSubSystem
class  IIterateableBufferChain
class  ILimitPendingWrites
 An interface to an object that manages the number of writes currently in progress and that can disallow any more write requests being made. Call CanWrite() when you wish to issue a new write request and when it returns you can issue your write and call WriteComplete() when the write is complete. More...
class  IManageBufferHandleLifeCycle
 A helper interface to remove a friend relationship between buffers and their allocators... More...
class  IManageBufferLifeCycle
 A helper interface to remove a friend relationship between buffers and their allocators... More...
class  IManageWorkerThreads
class  IMonitorAsyncFileReader
 An interface to allow a class to monitor an instance of an async file reader. More...
class  IMonitorAsyncFileWriter
 An interface to allow a class to monitor an instance of an async file writer. More...
class  IMonitorBufferAllocation
 An interface to allow a class to monitor the operation of a class that allocates buffers. The interface assumes that buffers go through the following life-cycle: created, allocated, released, destroyed. Allocators that pool buffers can allow a buffer to be created once and then allocated and released several times before being deleted. Incrementing a counter when OnBufferCreated() is called and decrementing it when OnBufferDestroyed() is called will give you a count of the number of buffers that are in existence at any one time. A corresponding counter that is incremented in OnBufferAllocated() and decremented when OnBufferReleased() is called will give a count of the buffers that are currently in use. More...
class  CIOPool
 An I/O thread pool implementing IIOPool. More...
class  CIOPoolBase
 An I/O thread pool implementing IIOPool. More...
class  CIOPoolEx
 An I/O thread pool implementing IIOPool. More...
class  IOutputStream
 An interface to an output stream (which may be sync or async). More...
class  IPoolBuffers
class  IProvideWorkItems
 A restricted interface onto a queue of work items (such as an I/O completion port, perhaps). More...
class  IRefCountedHandler
class  IStream
 An interface to an stream... More...
class  IUnsortedBufferChain
class  CJobEventManager
class  CLoggingAsyncFileWriterCallback
 A class that implements CAsyncFileWriter::Callback and logs errors and when the pending write limit is reached. More...
class  CMemoryInputOutputStream
 An object that implements IInputStream and ICloseableOutputStream on a memory buffer. More...
class  CMemoryInputStream
 An object that implements IInputStream on a memory buffer. More...
class  CNullAsyncFileReaderMonitor
 An object that implements IMonitorAsyncFileReader and does nothing. More...
class  CNullAsyncFileWriterMonitor
 An object that implements IMonitorAsyncFileWriter and does nothing. More...
class  CNullBufferAllocationMonitor
 An object that implements IMonitorBufferAllocation and does nothing. More...
class  CNullBufferPool
class  CPendingWriteLimiter
 An implementation of ILimitConnections. More...
class  CRetryAndRenameFileCreationFailureHandler
class  CRotatingAsyncFileLog
 A class that implements JetByteTools::ILogMessages to provide an asynchronous file log that uses overlapped I/O to perform writes to the log file. The log can be set to automatically rotate (i.e. create a new log file) after a set period of time or when the file grows to a particular size. More...
class  CSequencedBufferCollection
 A class that manages a collection of IBuffer instances which have a unique and ascending sequence number in them. You are allowed to push buffers into the collection in any order and to retrieve them only in the correct sequence. If you try and retrieve a buffer when the required buffer is not present then the collection will return null. Typical usage is to ensure the correct ordering of multiple overlapped read completions. All buffers are pushed into the collection using GetNext() and a buffer is only returned to the caller for processing if it is the next in sequence. This class takes a reference on a buffer when it is added to the collection and requires that the user of a buffer that has been removed from the collection releases that reference when done. More...
class  CSortedBufferChain
class  CSortedBufferProcessor
class  TTimeChangeAwareRotatingAsyncFileLog
 A class that implements JetByteTools::ILogMessages to provide an asynchronous file log that uses overlapped I/O to perform writes to the log file. The log can be set to automatically rotate (i.e. create a new log file) after a set period of time or when the file grows to a particular size. Aware of time changes that occur on the system. More...

Typedefs

typedef
TExpandableBuffer
< Data
LogData
typedef
JetByteTools::Core::TReferenceCountedSmartPointer
< JetByteTools::IO::IBuffer > 
CSmartBuffer
typedef
TExpandableBuffer
< Data
LogData
typedef
TTimeChangeAwareRotatingAsyncFileLog
< CFixedFileHeaderRotatingAsyncFileLog
CTimeChangeAwareFixedFileHeaderRotatingAsyncFileLog
typedef
TTimeChangeAwareRotatingAsyncFileLog
< CRotatingAsyncFileLog
CTimeChangeAwareRotatingAsyncFileLog

Functions

static const string s_newLogMessage ("****************New Log*****************\r\n")
static bool ValidateReadOptions (int readOptions)
static bool GetMarshallingDetails (long flags)
static
CBufferAllocator::BufferSize 
GetAllocationOverhead (UserDataIndex numberOfUserDataSlots)
static
CBufferAllocator::BufferSize 
CalculateBufferSize (UserDataIndex numberOfUserDataSlots, const IAllocateFixedSizedMemory &allocator)
static
CBufferAllocator::BufferSize 
CalculateBufferSize (CBufferAllocator::BufferSize bufferSize, UserDataIndex numberOfUserDataSlots, CBufferAllocator::AllocationFlags flags)
BYTE GetCounterFromPointer (const void *pBuffer)
IBuffer * SetCounterInPointer (const void *pBuffer, const BYTE counter)
IBuffer * RemoveCounterFromPointer (const void *pBuffer)
bool CanIncrementNullBufferCounter (const CBufferChainStoresNulls::NullBufferCount nullBufferCount)
CBufferChainStoresNulls::NullBufferCount ValidateNullBufferCounter (const CBufferChainStoresNulls::NullBufferCount nullBufferCount, const TCHAR *pFunctionName)
static HANDLE OpenFile (const _tstring &filePath)
static HANDLE OpenFile (const _tstring &filePath, CFileOutputStream::CreationDisposition disposition)
static DWORD MapDisposition (const CFileOutputStream::CreationDisposition disposition)
static const string s_lineEnd ("\r\n")
 JETBYTE_CLASS_ALIGNMENT (JETBYTE_IO_IBUFFER_ALIGNMENT_REQUIREMENT) IBuffer
static
CIOPoolBase::ThreadCount 
CalculateNumberOfThreads (CIOPoolBase::ThreadCount numThreads)
static DWORD GetTlsIndex ()
static void ReleaseTlsIndex ()
static void RemoveLastExtension (_tstring &filename, _tstring &extension)
static _tstring ProcessFileNameBase (const _tstring &fileNameBase)
static __int64 GetPreviousTime (const CSystemTime &now, CRotatingAsyncFileLog::RotationPeriod rotationPeriod)
static __int64 GetNextTime (const CSystemTime &now, CRotatingAsyncFileLog::RotationPeriod rotationPeriod)
static const _tstring s_logExtension (_T(".log"))

Variables

static const
CLocalTimeProvider 
s_timeProvider
static const Data s_lineEnd (reinterpret_cast< const BYTE * >("\r\n"), 2)
static const WORD ReadStartMask = 0x0F
static const WORD ReadIssueMask = 0xF0
static
CNullAsyncFileReaderMonitor 
s_nullMonitor
static
CNullAsyncFileWriterMonitor 
s_nullMonitor
static
CNullBufferAllocationMonitor 
s_nullMonitor
static
CNullBufferAllocationMonitor 
s_nullMonitor
static const DWORD s_dispositions []
static const size_t s_extraAlignmentBytes = JETBYTE_IO_IBUFFER_ALIGNMENT_REQUIREMENT - 1
static CLockableObject s_lock
static
CThreadLocalStorage * 
s_pTls = nullptr
static size_t s_ref = 0
static
CNullThreadPoolMonitor 
s_nullPoolMonitor
static const
CLocalTimeProvider 
s_timeProvider
static const Data s_lineEnd (reinterpret_cast< const BYTE * >("\r\n"), 2)
static
JETBYTE_CONSTEXPR
__int64 
s_intervalsInAnHour = 1000 * 60 * 60 * CSystemTime::IntervalsInAMillisecond
static
JETBYTE_CONSTEXPR
__int64 
s_intervalsInADay = s_intervalsInAnHour * 24
static
JETBYTE_CONSTEXPR
__int64 
s_intervalsInAWeek = s_intervalsInADay * 7


Typedef Documentation


Function Documentation

static CBufferAllocator::BufferSize CalculateBufferSize ( CBufferAllocator::BufferSize  bufferSize,
UserDataIndex  numberOfUserDataSlots,
CBufferAllocator::AllocationFlags  flags 
) [static]

static CBufferAllocator::BufferSize CalculateBufferSize ( UserDataIndex  numberOfUserDataSlots,
const IAllocateFixedSizedMemory allocator 
) [static]

static CIOPoolBase::ThreadCount CalculateNumberOfThreads ( CIOPoolBase::ThreadCount  numThreads  )  [static]

bool JetByteTools::IO::CanIncrementNullBufferCounter ( const CBufferChainStoresNulls::NullBufferCount  nullBufferCount  )  [inline]

static CBufferAllocator::BufferSize GetAllocationOverhead ( UserDataIndex  numberOfUserDataSlots  )  [static]

BYTE JetByteTools::IO::GetCounterFromPointer ( const void *  pBuffer  )  [inline]

static bool GetMarshallingDetails ( long  flags  )  [static]

static __int64 GetNextTime ( const CSystemTime &  now,
CRotatingAsyncFileLog::RotationPeriod  rotationPeriod 
) [static]

static __int64 GetPreviousTime ( const CSystemTime &  now,
CRotatingAsyncFileLog::RotationPeriod  rotationPeriod 
) [static]

static DWORD GetTlsIndex (  )  [static]

JetByteTools::IO::JETBYTE_CLASS_ALIGNMENT ( JETBYTE_IO_IBUFFER_ALIGNMENT_REQUIREMENT   ) 

Returns the amount of free space usable in the buffer. This is the same as the size of the buffer even if Consume() has been called and the start offset is not at 0. Be sure to call either RemoveSpaceAtFront() or MakeSpaceAtFront() with a 'spaceRequiredAtRear' value to ensure that there's enough space for you to use.

Returns the amount of free space available at the start of the buffer. That is, space that has been created by calling Consume(). This is accessible by calling MakeSpaceAtFront().

Moves all of the data to the front of the buffer, removing any start offset created by Consume().

Return a pointer to a WSABUF structure so that the buffer can be used in overlapped send and receive calls.

Splits the buffer into two. Allocates a new buffer and copies bytesToRemove bytes from the front of this buffer into the new buffer and then moves the rest of the contents of this buffer along to fill the gap. Returns a new buffer, remember to call Release() on it when you're done with it. Note that this is less efficient than calling SplitBufferFromBack() as there's more memory copying going on; however the semantics are considerably different: If this buffer initially contains XXXXXYYYYY and we call SplitBufferFromBack(5) then this buffer will contain XXXXX and the returned buffer will contain YYYYY. Whereas if we had called SplitBufferFromFront(5) this buffer would end up containing YYYYY and the new, returned, buffer would contain XXXXX.

Splits the buffer into two. Allocates a new buffer and copies bytesToRemove bytes from the supplied start offset into this buffer into the new buffer starting at offset 0 and then moves the rest of the contents of this buffer along to fill the gap. Note that we effectively remove startOffset + bytesToRemove bytes from this buffer and create a new buffer that contains bytesToRemove bytes. Returns a new buffer, remember to call Release() on it when you're done with it.

Splits the buffer into two. Allocates a new buffer and copies bytesToRemove bytes from the back of this buffer into the new buffer adjust the length of this buffer to reflect the data that was removed. Returns a new buffer that contains the last 'bytesToRemove' byes that were in this buffer before the call, remember to call Release() on it when you're done with it. Note that this is more efficient than calling SplitBuffer() as there's less memory copying going on; however the semantics are considerably different: If this buffer initially contains XXXXXYYYYY and we call SplitBufferFromBack(5) then this buffer will contain XXXXX and the returned buffer will contain YYYYY. Whereas if we had called SplitBufferFromFront(5) this buffer would end up containing YYYYY and the new, returned, buffer would contain XXXXX.

Allocates a new instance of an IBuffer from the same buffer allocator that was used to allocate this buffer.

Allocates a new instance of an IBuffer from the same buffer allocator that was used to allocate this buffer.

Allocates a new instance of an IBuffer from the same buffer allocator that was used to allocate this buffer and copies the contents of this buffer into it.

Removes bytesToConsume bytes from the front of this buffer by adjusting the start offset, no bytes are moved, but there's also no additional space in the buffer.

Removes bytesToRemove bytes from the front of this buffer and moves the rest of the contents of the buffer to fill the gap. Returns true if the buffer is now empty.

Moves the current buffer content along in the buffer to create an empty, but 'used' space of the specified size. Returns a pointer to the new space so that you can populate it directly. Note that this will "use up" any space that has been made available at the front of the buffer by Consume() and so does not always move the data.

Moves the current buffer content along in the buffer to create an empty, but 'used' space of the specified size. Returns a pointer to the new space so that you can populate it directly. Note that this will "use up" any space that has been made available at the front of the buffer by Consume() and so does not always move the data. Will ensure that there are 'spaceRequiredAtRead' bytes available at the end of the buffer. Specify CompactUnusedSpace for spaceRequiredAtRear to force data to be moved towards the front of the buffer if there is more space available than is required. Fails with an exception if spaceToAdd + spaceRequiredAtRead > GetTotalSpace().

Returns true if the reference count is 1. If called by code that owns a reference (and if you dont own a reference then you shouldn't be calling ANY method on a buffer) then this means that you own the only reference to this buffer.

Sets an arbitrary "operation" value in the buffer. This value is generally used to determine which overlapped operation the buffer was involed in.

Retrieves the arbitrary "operation" value from the buffer.

Sets an arbitrary "sequence number" value in the buffer. This value is generally used to maintain an ordering of overlapped operations.

Retrieves the arbitrary "sequence number" value from the buffer.

Stores the ioSize and lastError from an overlapped operation and an operations sequence number in the buffer.

Retrieves from the buffer the values set with SetOperationData().

Retrieves the operation sequence number from the buffer.

Returns true if the buffer is read only. If you need to be able to write to it then you should call GetWritableBuffer() to get a buffer which is writeable.

Returns a buffer which is guarenteed to be writable, this may be an expensive operation that requires a copy of the data to be made. Remember to call Release() on the returned buffer when you are finished with it.

We never delete instances of this interface; you must manage the lifetime of the class that implements it.

static DWORD JetByteTools::IO::MapDisposition ( const CFileOutputStream::CreationDisposition  disposition  )  [static]

static HANDLE OpenFile ( const _tstring &  filePath,
CFileOutputStream::CreationDisposition  disposition 
) [static]

static HANDLE OpenFile ( const _tstring &  filePath  )  [static]

static _tstring ProcessFileNameBase ( const _tstring &  fileNameBase  )  [static]

static void ReleaseTlsIndex (  )  [static]

IBuffer* JetByteTools::IO::RemoveCounterFromPointer ( const void *  pBuffer  )  [inline]

static void RemoveLastExtension ( _tstring &  filename,
_tstring &  extension 
) [static]

static const string JetByteTools::IO::s_lineEnd ( "\r\n"   )  [static]

static const _tstring JetByteTools::IO::s_logExtension ( _T(".log")   )  [static]

static const string JetByteTools::IO::s_newLogMessage ( "****************New Log*****************\r\n"   )  [static]

IBuffer* JetByteTools::IO::SetCounterInPointer ( const void *  pBuffer,
const BYTE  counter 
) [inline]

CBufferChainStoresNulls::NullBufferCount JetByteTools::IO::ValidateNullBufferCounter ( const CBufferChainStoresNulls::NullBufferCount  nullBufferCount,
const TCHAR pFunctionName 
) [inline]

static bool ValidateReadOptions ( int  readOptions  )  [static]


Variable Documentation

const WORD ReadIssueMask = 0xF0 [static]

const WORD ReadStartMask = 0x0F [static]

const DWORD s_dispositions[] [static]

Initial value:

{
   CREATE_NEW,
   CREATE_ALWAYS,
   OPEN_EXISTING,
   OPEN_ALWAYS,
   TRUNCATE_EXISTING,
   TRUNCATE_EXISTING
}

const size_t s_extraAlignmentBytes = JETBYTE_IO_IBUFFER_ALIGNMENT_REQUIREMENT - 1 [static]

JETBYTE_CONSTEXPR __int64 s_intervalsInADay = s_intervalsInAnHour * 24 [static]

JETBYTE_CONSTEXPR __int64 s_intervalsInAnHour = 1000 * 60 * 60 * CSystemTime::IntervalsInAMillisecond [static]

JETBYTE_CONSTEXPR __int64 s_intervalsInAWeek = s_intervalsInADay * 7 [static]

const Data s_lineEnd(reinterpret_cast< const BYTE * >("\r\n"), 2) [static]

const Data s_lineEnd(reinterpret_cast< const BYTE * >("\r\n"), 2) [static]

CLockableObject s_lock [static]

CThreadLocalStorage* s_pTls = nullptr [static]

size_t s_ref = 0 [static]


Generated on Sun Sep 12 19:09:18 2021 for The Server Framework - v7.4 by doxygen 1.5.3