FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
IO_Processor Class Reference

Intermediary I/O processing object for performing multi-threaded receive-and-process operations on a flow of messages. More...

#include <io_processor.hpp>

Public Types

enum  ThreadMode {
  NONE =0, READ_THREAD =1, PROCESS_THREAD =2, PROCESS_DURING_READ =4,
  BOTH_THREADS =READ_THREAD | PROCESS_THREAD, SEPARATE_READ_AND_PROCESS_THREADS =BOTH_THREADS, READ_AND_PROCESS_ON_SAME_THREAD =READ_THREAD | PROCESS_DURING_READ
}
 Mask to select threading modes. More...
 
enum  BlockMode {
  PACKET =1, _PACKET_HAS_SOURCE =2, _PACKET_HAS_RECEIVE_TIME =4, _PACKET_HAS_META_DATA =_PACKET_HAS_SOURCE | _PACKET_HAS_RECEIVE_TIME,
  _NOT_SOCKET =128, CONTIGUOUS_BYTE_STREAM =0, CONTIGUOUS_FILE_STREAM =_NOT_SOCKET, PACKET_WITH_SOURCE =PACKET | _PACKET_HAS_SOURCE,
  PACKET_WITH_TIME =PACKET | _PACKET_HAS_RECEIVE_TIME, PACKET_WITH_SOURCE_AND_TIME =PACKET | _PACKET_HAS_SOURCE | _PACKET_HAS_RECEIVE_TIME
}
 Blocking mode. More...
 

Public Member Functions

int submitOrProcessBlock (SharedBufferAllocRecord *rec)
 Submission routine that will either directly invoke the processing routine or notify the processing thread that it is available. More...
 
 IO_Processor (SharedMemoryVariableNode *parentNode, BufferRegion *mgr, IO_processBlockFP b_func, OS_HANDLE_TYPE h, ThreadMode tMode=NONE, void *userData=nullptr, BlockMode bMode=PACKET, IO_receiveBlockFP r_func=recvConsume, IO_consumeFP c_func=doConsumeLoop, IO_processFP p_func=doProcessLoop)
 Constructor for IO_Processor. More...
 
virtual ~IO_Processor ()
 
size_t dataOffset () const OME_ALWAYS_INLINE
 Return number of bytes reserved for meta data on each data element. More...
 
unsigned char * bufferAddress (SharedBufferAllocRecord *rec, size_t *bufferLen=nullptr) const OME_ALWAYS_INLINE
 Return physical address of a buffer within the context of the local process' address space. More...
 
IO_metaBlock_headerbufferHeaderAddress (SharedBufferAllocRecord *rec, size_t *headerLen=nullptr) const OME_ALWAYS_INLINE
 Return physical address of meta block header within the context of the local process' address space. More...
 
const char * getLabel () const OME_ALWAYS_INLINE NONNULL_RETURN
 
void setLabel (const char *name) OME_ALWAYS_INLINE NONNULL_CLASS_PARAMETERS(2)
 
void setPacketsProcessedIncrement (int32_t incVal)
 
void setReadAttempts (uint32_t count) OME_ALWAYS_INLINE
 Set read attempts before blocking. More...
 
uint32_t getReadAttempts () const OME_ALWAYS_INLINE
 Get limit on read attempts before blocking. More...
 
void setReadTimeout (uint32_t count) OME_ALWAYS_INLINE
 Set read timeout. More...
 
uint32_t getReadTimeout () const OME_ALWAYS_INLINE
 Get limit on read attempts before blocking. More...
 
void setExtraData (void *data) OME_ALWAYS_INLINE
 Set extra information value. More...
 
void * getExtraData () const OME_ALWAYS_INLINE
 Retrieve extra information value. More...
 
void setMaxPacketSize (size_t bytes) OME_ALWAYS_INLINE
 Set MTU. More...
 
void setProcessRoutine (IO_processBlockFP func) OME_ALWAYS_INLINE
 Set processing routine. More...
 
void setProcessLoopRoutine (IO_processFP func) OME_ALWAYS_INLINE
 Set processing loop routine. More...
 
void setConsumeLoopRoutine (IO_consumeFP func) OME_ALWAYS_INLINE
 Set consume loop routine. More...
 
void setConsumeRoutine (IO_receiveBlockFP func) OME_ALWAYS_INLINE
 Set consume routine. More...
 
uint32_t getThreadMode () const OME_ALWAYS_INLINE
 Get requested thread modes. More...
 
int setThreadMode (ThreadMode mode)
 Set threading mode. More...
 
void setBlockingMode (BlockMode mode)
 Set block delivery mode. More...
 
int stopThread (uint32_t modes)
 Request stop. More...
 
int interruptThread (uint32_t modes, bool force=false)
 Interrupt blocked thread. More...
 
int waitForThreadStart (uint32_t mode)
 Wait for threads to start. More...
 
int waitForThreadExit (uint32_t modes)
 Wait for threads to terminate. More...
 
int waitForDataToProcess (bool alreadyLocked=false)
 Wait for data to arrive. More...
 
int waitForDataToProcessOrUntil (const struct timespec *maxWaitUntil, bool alreadyLocked=false)
 Wait for data to arrive or until a point in time. More...
 
int noteDataToProcess (bool alreadyLocked=false)
 Note new data has arrived. More...
 

Static Public Member Functions

static ssize_t recvConsume (SharedBufferAllocRecord *rec, class IO_Processor *controller)
 
static int doConsumeLoop (IO_Processor *controller)
 Standard consume loop to receive incoming data. More...
 
static int doProcessLoop (IO_Processor *controller)
 Standard processing loop to process data on separate thread; works in conjunction with doConsumeLoop(). More...
 

Public Attributes

BufferRegionbfrManager
 buffer region More...
 
IO_Processor_Statisticsstatistics
 statistics More...
 
TimedMutexmutex
 
TimedConditioncondition
 
IO_processFP processRoutine
 
IO_processBlockFP processBlockRoutine
 
IO_consumeFP consumeRoutine
 
IO_receiveBlockFP recvRoutine
 
void * extraData
 arbitrary extra data More...
 
pthread_t consumeThreadID
 
pthread_t processThreadID
 
OS_HANDLE_TYPE descriptor
 
uint32_t descriptorFlags
 
int32_t packetsProcessedIncrement
 
char label [24]
 
size_t maxPacketSize
 max to receive in one go More...
 
unsigned int lastReadTimeout
 
unsigned char threadStartedState
 
unsigned char currentThreadState
 
unsigned char desiredThreadState
 
unsigned char stopRequested
 
unsigned char blockingMode
 

Detailed Description

Intermediary I/O processing object for performing multi-threaded receive-and-process operations on a flow of messages.

Member Enumeration Documentation

◆ BlockMode

Blocking mode.

Enumerator
PACKET 

packet message unit, like a datagram

_PACKET_HAS_SOURCE 

bit flag indicating source information

_PACKET_HAS_RECEIVE_TIME 

bit flag indicating arrival time

_PACKET_HAS_META_DATA 

bit flags indicating meta data present

_NOT_SOCKET 

force use of read vs. recv().

CONTIGUOUS_BYTE_STREAM 

contiguous byte stream from socket

CONTIGUOUS_FILE_STREAM 

contiguous byte stream from file

PACKET_WITH_SOURCE 

packet message unit including source address

PACKET_WITH_TIME 

packet message with arrival time

PACKET_WITH_SOURCE_AND_TIME 

packet message with source address and arrival time

◆ ThreadMode

Mask to select threading modes.

Enumerator
NONE 

No threads will be spawned.

READ_THREAD 

A read thread will be spawned.

PROCESS_THREAD 

A processing thread will be spawned

PROCESS_DURING_READ 

Processing will be performed by the read thread.

BOTH_THREADS 

Both a read and a processing thread will be spawned.

SEPARATE_READ_AND_PROCESS_THREADS 
READ_AND_PROCESS_ON_SAME_THREAD 

a single spawned read thread will do both read-and-processing

Constructor & Destructor Documentation

◆ IO_Processor()

◆ ~IO_Processor()

IO_Processor::~IO_Processor ( )
virtual

References condition, mutex, and statistics.

Member Function Documentation

◆ bufferAddress()

◆ bufferHeaderAddress()

IO_metaBlock_header* IO_Processor::bufferHeaderAddress ( SharedBufferAllocRecord rec,
size_t *  headerLen = nullptr 
) const
inline

Return physical address of meta block header within the context of the local process' address space.

References bfrManager, BufferRegion::blockAddress(), and dataOffset().

Referenced by processPacketFromSourceUsingClass(), and recvConsume().

◆ dataOffset()

size_t IO_Processor::dataOffset ( ) const
inline

Return number of bytes reserved for meta data on each data element.

References _PACKET_HAS_META_DATA, and blockingMode.

Referenced by bufferAddress(), and bufferHeaderAddress().

◆ doConsumeLoop()

int IO_Processor::doConsumeLoop ( IO_Processor controller)
static

◆ doProcessLoop()

◆ getExtraData()

void* IO_Processor::getExtraData ( ) const
inline

◆ getLabel()

const char* IO_Processor::getLabel ( ) const
inline

References label.

◆ getReadAttempts()

uint32_t IO_Processor::getReadAttempts ( ) const
inline

Get limit on read attempts before blocking.

References IO_Processor_Statistics::readAttemptsBeforeBlocking, and statistics.

Referenced by recvConsume().

◆ getReadTimeout()

uint32_t IO_Processor::getReadTimeout ( ) const
inline

Get limit on read attempts before blocking.

References IO_Processor_Statistics::maxReadTimeout, and statistics.

Referenced by recvConsume().

◆ getThreadMode()

uint32_t IO_Processor::getThreadMode ( ) const
inline

Get requested thread modes.

References desiredThreadState.

Referenced by LogManager::~LogManager().

◆ interruptThread()

int IO_Processor::interruptThread ( uint32_t  modes,
bool  force = false 
)

Interrupt blocked thread.

References consumeThreadID, currentThreadState, PROCESS_THREAD, processThreadID, READ_THREAD, and SIGIO.

Referenced by stopThread().

◆ noteDataToProcess()

◆ recvConsume()

◆ setBlockingMode()

void IO_Processor::setBlockingMode ( BlockMode  mode)

Set block delivery mode.

References blockingMode.

Referenced by IO_Processor().

◆ setConsumeLoopRoutine()

void IO_Processor::setConsumeLoopRoutine ( IO_consumeFP  func)
inline

Set consume loop routine.

References consumeRoutine.

Referenced by IO_Processor().

◆ setConsumeRoutine()

void IO_Processor::setConsumeRoutine ( IO_receiveBlockFP  func)
inline

Set consume routine.

References recvRoutine.

Referenced by IO_Processor().

◆ setExtraData()

void IO_Processor::setExtraData ( void *  data)
inline

Set extra information value.

References extraData.

Referenced by IO_Processor().

◆ setLabel()

void IO_Processor::setLabel ( const char *  name)
inline

References label, and safe_strcpy.

◆ setMaxPacketSize()

void IO_Processor::setMaxPacketSize ( size_t  bytes)
inline

Set MTU.

References maxPacketSize.

◆ setPacketsProcessedIncrement()

void IO_Processor::setPacketsProcessedIncrement ( int32_t  incVal)
inline

◆ setProcessLoopRoutine()

void IO_Processor::setProcessLoopRoutine ( IO_processFP  func)
inline

Set processing loop routine.

References processRoutine.

Referenced by IO_Processor().

◆ setProcessRoutine()

void IO_Processor::setProcessRoutine ( IO_processBlockFP  func)
inline

Set processing routine.

References processBlockRoutine.

Referenced by HTTPstatusLog::becomeEventStream(), and IO_Processor().

◆ setReadAttempts()

void IO_Processor::setReadAttempts ( uint32_t  count)
inline

Set read attempts before blocking.

References IO_Processor_Statistics::readAttemptsBeforeBlocking, and statistics.

Referenced by ReplumbAndLog::ReplumbAndLog().

◆ setReadTimeout()

void IO_Processor::setReadTimeout ( uint32_t  count)
inline

Set read timeout.

References IO_Processor_Statistics::maxReadTimeout, and statistics.

◆ setThreadMode()

◆ stopThread()

◆ submitOrProcessBlock()

int IO_Processor::submitOrProcessBlock ( SharedBufferAllocRecord rec)

Submission routine that will either directly invoke the processing routine or notify the processing thread that it is available.

Not normally used directly, but available for special use cases.

References bfrManager, IO_Processor_Statistics::bytesProcessed, currentThreadState, mutex, noteDataToProcess(), IO_Processor_Statistics::packetsProcessed, packetsProcessedIncrement, IO_Processor_Statistics::packetsRead, PROCESS_DURING_READ, BufferRegion::returnBlock(), and statistics.

Referenced by doConsumeLoop(), and LogManager::writeDataToBuffer().

◆ waitForDataToProcess()

int IO_Processor::waitForDataToProcess ( bool  alreadyLocked = false)

◆ waitForDataToProcessOrUntil()

int IO_Processor::waitForDataToProcessOrUntil ( const struct timespec *  maxWaitUntil,
bool  alreadyLocked = false 
)

◆ waitForThreadExit()

int IO_Processor::waitForThreadExit ( uint32_t  modes)

◆ waitForThreadStart()

int IO_Processor::waitForThreadStart ( uint32_t  mode)

Member Data Documentation

◆ bfrManager

◆ blockingMode

unsigned char IO_Processor::blockingMode

◆ condition

◆ consumeRoutine

IO_consumeFP IO_Processor::consumeRoutine

Referenced by setConsumeLoopRoutine().

◆ consumeThreadID

pthread_t IO_Processor::consumeThreadID

◆ currentThreadState

◆ descriptor

◆ descriptorFlags

uint32_t IO_Processor::descriptorFlags

Referenced by IO_Processor(), and recvConsume().

◆ desiredThreadState

◆ extraData

void* IO_Processor::extraData

arbitrary extra data

Referenced by getExtraData(), and setExtraData().

◆ label

char IO_Processor::label[24]

Referenced by getLabel(), IO_Processor(), and setLabel().

◆ lastReadTimeout

unsigned int IO_Processor::lastReadTimeout

Referenced by IO_Processor(), and recvConsume().

◆ maxPacketSize

size_t IO_Processor::maxPacketSize

max to receive in one go

Referenced by doConsumeLoop(), IO_Processor(), recvConsume(), and setMaxPacketSize().

◆ mutex

◆ packetsProcessedIncrement

int32_t IO_Processor::packetsProcessedIncrement

◆ processBlockRoutine

IO_processBlockFP IO_Processor::processBlockRoutine

Referenced by doProcessLoop(), and setProcessRoutine().

◆ processRoutine

IO_processFP IO_Processor::processRoutine

Referenced by setProcessLoopRoutine().

◆ processThreadID

pthread_t IO_Processor::processThreadID

◆ recvRoutine

IO_receiveBlockFP IO_Processor::recvRoutine

Referenced by doConsumeLoop(), and setConsumeRoutine().

◆ statistics

◆ stopRequested

◆ threadStartedState

unsigned char IO_Processor::threadStartedState

The documentation for this class was generated from the following files:
Generated: Fri Jul 31 2020 18:19:16
Support Information