Class DataInputQueue

Class Documentation

class DataInputQueue

Access to send messages through XLink stream

Public Functions

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)
~DataInputQueue()
bool 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.

void close()

Closes the queue and the underlying thread

void setMaxDataSize(std::size_t maxSize)

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

Parameters:

maxSize – Maximum message size to add to queue

std::size_t getMaxDataSize()

Gets maximum queue size.

Returns:

Maximum message size

void setBlocking(bool blocking)

Sets queue behavior when full (maxSize)

Parameters:

blocking – Specifies if block or overwrite the oldest message in the queue

bool getBlocking() const

Gets current queue behavior when full (maxSize)

Returns:

True if blocking, false otherwise

void setMaxSize(unsigned int maxSize)

Sets queue maximum size

Parameters:

maxSize – Specifies maximum number of messages in the queue

unsigned int getMaxSize() const

Gets queue maximum size

Returns:

Maximum queue size

std::string getName() const

Gets queues name

Returns:

Queue name

void 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:

rawMsg – Message to add to the queue

void 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:

msg – Message to add to the queue

void 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:

msg – Message to add to the queue

bool 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:
  • rawMsg – Message to add to the queue

  • timeout – Maximum duration to block in milliseconds

bool 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:
  • msg – Message to add to the queue

  • timeout – Maximum duration to block in milliseconds

bool 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:
  • msg – Message to add to the queue

  • timeout – Maximum duration to block in milliseconds