Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit beca9b3

Browse files
committed
Merge branch 'ajaus/bridge-hang-when-timeouts-disabled' into 'main'
[REMIX-3874] Plumb bridge server termination value to the command peek and pull functions. See merge request lightspeedrtx/bridge-remix-nv!144
2 parents 12eb1e1 + 4f864bf commit beca9b3

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/util/util_atomiccircularqueue.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ namespace bridge_util {
116116

117117
// Returns a ref to the first element in the queue
118118
// Note: Blocks if the queue is empty
119-
const T& peek(Result& result, const DWORD timeoutMS = 0) const {
119+
const T& peek(Result& result, const DWORD timeoutMS = 0, std::atomic<bool>* const pbEarlyOutSignal = nullptr) const {
120120
ULONGLONG start = 0, curTick;
121121
do {
122122
const auto currentWrite = m_write->load(std::memory_order_relaxed);
@@ -131,6 +131,11 @@ namespace bridge_util {
131131

132132
curTick = GetTickCount64();
133133
start = start > 0 ? start : curTick;
134+
135+
if (pbEarlyOutSignal && pbEarlyOutSignal->load()) {
136+
result = Result::Timeout;
137+
return m_default;
138+
}
134139
} while (timeoutMS == 0 || start + timeoutMS > curTick);
135140

136141
result = Result::Timeout;
@@ -140,7 +145,7 @@ namespace bridge_util {
140145

141146
// Returns a copy to the first element in queue, AND removes it
142147
// Note: Blocks if queue is empty
143-
const T& pull(Result& result, const DWORD timeoutMS = 0) {
148+
const T& pull(Result& result, const DWORD timeoutMS = 0, std::atomic<bool>* const pbEarlyOutSignal = nullptr) {
144149
ULONGLONG start = 0, curTick;
145150
do {
146151
const auto currentWrite = m_write->load(std::memory_order_relaxed);
@@ -156,6 +161,11 @@ namespace bridge_util {
156161

157162
curTick = GetTickCount64();
158163
start = start > 0 ? start : curTick;
164+
165+
if (pbEarlyOutSignal && pbEarlyOutSignal->load()) {
166+
result = Result::Timeout;
167+
return m_default;
168+
}
159169
} while (timeoutMS == 0 || start + timeoutMS > curTick);
160170

161171
return m_default;

src/util/util_bridgecommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ DECL_BRIDGE_FUNC(bridge_util::Result, waitForCommand, const Commands::D3D9Comman
171171
uint32_t attemptNum = 0;
172172
do {
173173
Result result;
174-
Header header = getReaderChannel().commands->peek(result, peekTimeoutMS);
174+
Header header = getReaderChannel().commands->peek(result, peekTimeoutMS, pbEarlyOutSignal);
175175

176176
switch (result) {
177177

0 commit comments

Comments
 (0)