non-blocking http
All checks were successful
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 2m58s
CI / Windows Release Package (push) Has been skipped

This commit is contained in:
Aiden
2026-05-12 15:05:54 +10:00
parent 95b4a54326
commit c5fd8e72b4
4 changed files with 57 additions and 8 deletions

View File

@@ -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);
}

View File

@@ -21,7 +21,9 @@ public:
void Start(const std::string& shaderId, ArtifactCallback onArtifactReady, ErrorCallback onError);
void Start(const std::string& layerId, const std::string& shaderId, ArtifactCallback onArtifactReady, ErrorCallback onError);
void RequestStop();
void Stop();
bool CanStopWithoutWaiting() const;
private:
void ThreadMain();
@@ -29,6 +31,7 @@ private:
RuntimeSlangShaderCompiler mCompiler;
std::thread mThread;
std::atomic<bool> mStopping{ false };
std::atomic<bool> mFinished{ true };
std::string mLayerId;
ArtifactCallback mOnArtifactReady;
ErrorCallback mOnError;