Skip to content

Commit

Permalink
deprecate thread unsafe isClosed() in DataInputQueue, DataOutputQueue
Browse files Browse the repository at this point in the history
- partial fix luxonis#520
  • Loading branch information
diablodale committed Mar 14, 2023
1 parent c0e62b4 commit 84d41ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/depthai/device/DataQueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ class DataOutputQueue {

/**
* Check whether queue is closed
*
* @warning This function is thread-unsafe and may return incorrect values.
*/
bool isClosed() const;
[[deprecated("thread-unsafe and may return incorrect values")]] bool isClosed() const;

/**
* Closes the queue and the underlying thread
Expand Down Expand Up @@ -355,8 +357,10 @@ class DataInputQueue {

/**
* Check whether queue is closed
*
* @warning This function is thread-unsafe and may return incorrect values.
*/
bool isClosed() const;
[[deprecated("thread-unsafe and may return incorrect values")]] bool isClosed() const;

/**
* Closes the queue and the underlying thread
Expand Down
8 changes: 8 additions & 0 deletions src/device/DataQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ DataOutputQueue::DataOutputQueue(const std::shared_ptr<XLinkConnection> conn, co
});
}

// BUGBUG this function is thread-unsafe. The idea of "isClosed" is ephemerial and
// since there is no mutex lock, its state is outdated and invalid even before
// the logical NOT in this function. This calculated boolean then continues to degrade
// in validity as it is returned by value to the caller
bool DataOutputQueue::isClosed() const {
return !running;
}
Expand Down Expand Up @@ -220,6 +224,10 @@ DataInputQueue::DataInputQueue(
});
}

// BUGBUG this function is thread-unsafe. The idea of "isClosed" is ephemerial and
// since there is no mutex lock, its state is outdated and invalid even before
// the logical NOT in this function. This calculated boolean then continues to degrade
// in validity as it is returned by value to the caller
bool DataInputQueue::isClosed() const {
return !running;
}
Expand Down

0 comments on commit 84d41ca

Please sign in to comment.