non-blocking http
This commit is contained in:
@@ -22,19 +22,31 @@ void RuntimeShaderBridge::Start(const std::string& layerId, const std::string& s
|
||||
mOnArtifactReady = std::move(onArtifactReady);
|
||||
mOnError = std::move(onError);
|
||||
mStopping.store(false, std::memory_order_release);
|
||||
mFinished.store(false, std::memory_order_release);
|
||||
mCompiler.StartShaderBuild(shaderId);
|
||||
mThread = std::thread([this]() { ThreadMain(); });
|
||||
}
|
||||
|
||||
void RuntimeShaderBridge::Stop()
|
||||
void RuntimeShaderBridge::RequestStop()
|
||||
{
|
||||
mStopping.store(true, std::memory_order_release);
|
||||
}
|
||||
|
||||
void RuntimeShaderBridge::Stop()
|
||||
{
|
||||
RequestStop();
|
||||
if (mThread.joinable())
|
||||
mThread.join();
|
||||
mCompiler.Stop();
|
||||
mLayerId.clear();
|
||||
mOnArtifactReady = ArtifactCallback();
|
||||
mOnError = ErrorCallback();
|
||||
mFinished.store(true, std::memory_order_release);
|
||||
}
|
||||
|
||||
bool RuntimeShaderBridge::CanStopWithoutWaiting() const
|
||||
{
|
||||
return mFinished.load(std::memory_order_acquire) && !mCompiler.Running();
|
||||
}
|
||||
|
||||
void RuntimeShaderBridge::ThreadMain()
|
||||
@@ -54,8 +66,10 @@ void RuntimeShaderBridge::ThreadMain()
|
||||
{
|
||||
mOnError(build.message);
|
||||
}
|
||||
mFinished.store(true, std::memory_order_release);
|
||||
return;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
}
|
||||
mFinished.store(true, std::memory_order_release);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user