Skip to content

Commit e901932

Browse files
committed
waitIDE() with timeout (ms)
1 parent c253aef commit e901932

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

emmy_core/emmy_facade.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,17 @@ bool EmmyFacade::PipeConnect(lua_State* L, const std::string& name, std::string&
119119
return suc;
120120
}
121121

122-
void EmmyFacade::WaitIDE(bool force) {
122+
void EmmyFacade::WaitIDE(bool force, int timeout) {
123123
if (transporter != nullptr
124124
&& (transporter->IsServerMode() || force)
125125
&& !isWaitingForIDE
126126
&& !isIDEReady) {
127127
isWaitingForIDE = true;
128128
std::unique_lock<std::mutex> lock(waitIDEMutex);
129-
waitIDECV.wait(lock);
129+
if (timeout > 0)
130+
waitIDECV.wait_for(lock, std::chrono::milliseconds(timeout));
131+
else
132+
waitIDECV.wait(lock);
130133
isWaitingForIDE = false;
131134
}
132135
}

emmy_core/emmy_facade.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class EmmyFacade {
5050
int BreakHere(lua_State* L);
5151
int OnConnect(bool suc);
5252
int OnDisconnect();
53-
void WaitIDE(bool force = false);
53+
void WaitIDE(bool force = false, int timeout = 0);
5454
void OnReceiveMessage(const rapidjson::Document& document);
5555
void OnBreak(lua_State* L);
5656
void Destroy();

0 commit comments

Comments
 (0)