Skip to content

Commit e3ee6e5

Browse files
Make circular buffer timeout configurable
1 parent 8dd6db6 commit e3ee6e5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/support/circular.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ namespace PCSX {
3838

3939
template <typename T, size_t BS = 1024>
4040
class Circular {
41+
using ms = std::chrono::milliseconds;
42+
4143
public:
4244
static constexpr size_t BUFFER_SIZE = BS;
4345
size_t available() {
@@ -48,13 +50,12 @@ class Circular {
4850
std::unique_lock<std::mutex> l(m_mu);
4951
return bufferedLocked();
5052
}
51-
bool enqueue(const T* data, size_t N) {
53+
bool enqueue(const T* data, size_t N, ms maxWait = ms{200}) {
5254
if (N > BUFFER_SIZE) {
5355
throw std::runtime_error("Trying to enqueue too much data");
5456
}
5557
std::unique_lock<std::mutex> l(m_mu);
56-
using namespace std::chrono_literals;
57-
bool safe = m_cv.wait_for(l, 200ms, [this, N]() -> bool { return N < availableLocked(); });
58+
bool safe = m_cv.wait_for(l, maxWait, [this, N]() -> bool { return N < availableLocked(); });
5859
if (safe) enqueueSafe(data, N);
5960
return safe;
6061
}

0 commit comments

Comments
 (0)