Public Member Functions | Private Attributes | List of all members
dai::DataInputQueue Class Reference

#include <DataQueue.hpp>

Public Member Functions

void close ()
 
 DataInputQueue (const std::shared_ptr< XLinkConnection > conn, const std::string &streamName, unsigned int maxSize=16, bool blocking=true, std::size_t maxDataSize=device::XLINK_USB_BUFFER_MAX_SIZE)
 
bool getBlocking () const
 
std::size_t getMaxDataSize ()
 
unsigned int getMaxSize () const
 
std::string getName () const
 
bool isClosed () const
 
void send (const ADatatype &msg)
 
bool send (const ADatatype &msg, std::chrono::milliseconds timeout)
 
void send (const std::shared_ptr< ADatatype > &msg)
 
bool send (const std::shared_ptr< ADatatype > &msg, std::chrono::milliseconds timeout)
 
void send (const std::shared_ptr< RawBuffer > &rawMsg)
 
bool send (const std::shared_ptr< RawBuffer > &rawMsg, std::chrono::milliseconds timeout)
 
void setBlocking (bool blocking)
 
void setMaxDataSize (std::size_t maxSize)
 
void setMaxSize (unsigned int maxSize)
 
 ~DataInputQueue ()
 

Private Attributes

std::string exceptionMessage
 
std::atomic< std::size_t > maxDataSize {device::XLINK_USB_BUFFER_MAX_SIZE}
 
const std::string name
 
LockingQueue< std::shared_ptr< RawBuffer > > queue
 
std::atomic< bool > running {true}
 
std::thread writingThread
 

Detailed Description

Access to send messages through XLink stream

Definition at line 344 of file DataQueue.hpp.

Constructor & Destructor Documentation

◆ DataInputQueue()

dai::DataInputQueue::DataInputQueue ( const std::shared_ptr< XLinkConnection conn,
const std::string &  streamName,
unsigned int  maxSize = 16,
bool  blocking = true,
std::size_t  maxDataSize = device::XLINK_USB_BUFFER_MAX_SIZE 
)

Definition at line 197 of file DataQueue.cpp.

◆ ~DataInputQueue()

dai::DataInputQueue::~DataInputQueue ( )

Definition at line 282 of file DataQueue.cpp.

Member Function Documentation

◆ close()

void dai::DataInputQueue::close ( )

Closes the queue and the underlying thread

Definition at line 268 of file DataQueue.cpp.

◆ getBlocking()

bool dai::DataInputQueue::getBlocking ( ) const

Gets current queue behavior when full (maxSize)

Returns
True if blocking, false otherwise

Definition at line 295 of file DataQueue.cpp.

◆ getMaxDataSize()

std::size_t dai::DataInputQueue::getMaxDataSize ( )

Gets maximum queue size.

Returns
Maximum message size

Definition at line 315 of file DataQueue.cpp.

◆ getMaxSize()

unsigned int dai::DataInputQueue::getMaxSize ( ) const

Gets queue maximum size

Returns
Maximum queue size

Definition at line 305 of file DataQueue.cpp.

◆ getName()

std::string dai::DataInputQueue::getName ( ) const

Gets queues name

Returns
Queue name

Definition at line 319 of file DataQueue.cpp.

◆ isClosed()

bool dai::DataInputQueue::isClosed ( ) const

Check whether queue is closed

Warning
This function is thread-unsafe and may return outdated incorrect values. It is only meant for use in simple single-threaded code. Well written code should handle exceptions when calling any DepthAI apis to handle hardware events and multithreaded use.

Definition at line 264 of file DataQueue.cpp.

◆ send() [1/6]

void dai::DataInputQueue::send ( const ADatatype msg)

Adds a message to the queue, which will be picked up and sent to the device. Can either block if 'blocking' behavior is true or overwrite oldest

Parameters
msgMessage to add to the queue

Definition at line 341 of file DataQueue.cpp.

◆ send() [2/6]

bool dai::DataInputQueue::send ( const ADatatype msg,
std::chrono::milliseconds  timeout 
)

Adds message to the queue, which will be picked up and sent to the device. Can either block until timeout if 'blocking' behavior is true or overwrite oldest

Parameters
msgMessage to add to the queue
timeoutMaximum duration to block in milliseconds

Definition at line 362 of file DataQueue.cpp.

◆ send() [3/6]

void dai::DataInputQueue::send ( const std::shared_ptr< ADatatype > &  msg)

Adds a message to the queue, which will be picked up and sent to the device. Can either block if 'blocking' behavior is true or overwrite oldest

Parameters
msgMessage to add to the queue

Definition at line 336 of file DataQueue.cpp.

◆ send() [4/6]

bool dai::DataInputQueue::send ( const std::shared_ptr< ADatatype > &  msg,
std::chrono::milliseconds  timeout 
)

Adds message to the queue, which will be picked up and sent to the device. Can either block until timeout if 'blocking' behavior is true or overwrite oldest

Parameters
msgMessage to add to the queue
timeoutMaximum duration to block in milliseconds

Definition at line 357 of file DataQueue.cpp.

◆ send() [5/6]

void dai::DataInputQueue::send ( const std::shared_ptr< RawBuffer > &  rawMsg)

Adds a raw message to the queue, which will be picked up and sent to the device. Can either block if 'blocking' behavior is true or overwrite oldest

Parameters
rawMsgMessage to add to the queue

Definition at line 323 of file DataQueue.cpp.

◆ send() [6/6]

bool dai::DataInputQueue::send ( const std::shared_ptr< RawBuffer > &  rawMsg,
std::chrono::milliseconds  timeout 
)

Adds message to the queue, which will be picked up and sent to the device. Can either block until timeout if 'blocking' behavior is true or overwrite oldest

Parameters
rawMsgMessage to add to the queue
timeoutMaximum duration to block in milliseconds

Definition at line 345 of file DataQueue.cpp.

◆ setBlocking()

void dai::DataInputQueue::setBlocking ( bool  blocking)

Sets queue behavior when full (maxSize)

Parameters
blockingSpecifies if block or overwrite the oldest message in the queue

Definition at line 290 of file DataQueue.cpp.

◆ setMaxDataSize()

void dai::DataInputQueue::setMaxDataSize ( std::size_t  maxSize)

Sets maximum message size. If message is larger than specified, then an exception is issued.

Parameters
maxSizeMaximum message size to add to queue

Definition at line 311 of file DataQueue.cpp.

◆ setMaxSize()

void dai::DataInputQueue::setMaxSize ( unsigned int  maxSize)

Sets queue maximum size

Parameters
maxSizeSpecifies maximum number of messages in the queue

Definition at line 300 of file DataQueue.cpp.

Member Data Documentation

◆ exceptionMessage

std::string dai::DataInputQueue::exceptionMessage
private

Definition at line 348 of file DataQueue.hpp.

◆ maxDataSize

std::atomic<std::size_t> dai::DataInputQueue::maxDataSize {device::XLINK_USB_BUFFER_MAX_SIZE}
private

Definition at line 350 of file DataQueue.hpp.

◆ name

const std::string dai::DataInputQueue::name
private

Definition at line 349 of file DataQueue.hpp.

◆ queue

LockingQueue<std::shared_ptr<RawBuffer> > dai::DataInputQueue::queue
private

Definition at line 345 of file DataQueue.hpp.

◆ running

std::atomic<bool> dai::DataInputQueue::running {true}
private

Definition at line 347 of file DataQueue.hpp.

◆ writingThread

std::thread dai::DataInputQueue::writingThread
private

Definition at line 346 of file DataQueue.hpp.


The documentation for this class was generated from the following files:


depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:20