Harden cross thread code, and fix retriggering / busy check.

By actually looking at the result.
nix
Owen Green 6 years ago
parent 48dc167c1b
commit e5798aaa35

@ -20,6 +20,7 @@ under the European Unions Horizon 2020 research and innovation programme
#include <data/TensorTypes.hpp>
#include <FluidVersion.hpp>
#include <SC_PlugIn.hpp>
#include <atomic>
#include <algorithm>
#include <memory>
#include <string>
@ -43,11 +44,12 @@ struct WrapperState
typename Client::ParamSetType params;
Client client;
Node* mNode;
bool mCancelled{false};
bool mJobDone{false};
bool mHasTriggered{false};
bool mSynchronous{false};
bool mInNRT{false};
std::atomic<bool> mCancelled{false};
std::atomic<bool> mJobDone{false};
std::atomic<bool> mHasTriggered{false};
std::atomic<bool> mSynchronous{false};
std::atomic<bool> mInNRT{false};
std::atomic<bool> mNodeAlive{true};
Result mResult{};
};
@ -341,7 +343,8 @@ public:
~NonRealTime()
{
if (mWrapper->client().state() == ProcessState::kProcessing)
auto state = mWrapper->client().state();
if (state == ProcessState::kProcessing)
{
std::cout << Wrapper::getName() << ": Processing cancelled" << std::endl;
Wrapper::getInterfaceTable()->fSendNodeReply(&mParent->mNode, 1, "/done",
@ -408,21 +411,29 @@ public:
if(!f->mData) return;
auto w = static_cast<SharedState*>(f->mData);
SharedState& s = *w;
s->mInNRT = true;
s->mJobDone = false;
s->mCancelled = false;
Result result = validateParameters(s->params);
if (!result.ok())
{
std::cout << "ERROR: " << Wrapper::getName() << ": "
<< result.message().c_str() << std::endl;
s->mInNRT = false;
return;
}
s->client.setSynchronous(s->mSynchronous);
s->client.enqueue(s->params);
s->mResult = s->client.process();
result = s->client.enqueue(s->params);
if (!result.ok())
{
std::cout << "ERROR: " << Wrapper::getName() << ": "
<< result.message().c_str() << std::endl;
s->mInNRT = false;
return;
}
s->mJobDone = false;
s->mCancelled = false;
s->mHasTriggered = true;
s->mResult = s->client.process();
s->mInNRT = false;
w->~SharedState();
f->mWorld->ft->fRTFree(f->mWorld,w);
@ -483,8 +494,8 @@ public:
static bool exchangeBuffers(World* world, void* data)
{
if(!data) return false;
SharedState& s = *(static_cast<SharedState*>(data));
if(!s->mNodeAlive) return false;
s->params.template forEachParamType<BufferT, AssignBuffer>(world);
// At this point, we can see if we're finished and let the language know (or
// it can wait for the doneAction, but that takes extra time) use replyID to
@ -1401,6 +1412,12 @@ public:
impl::FluidSCWrapperBase<Client>::init();
}
~FluidSCWrapper()
{
mState->mNodeAlive = false;
}
std::shared_ptr<WrapperState<Client>>& state() { return mState; }

Loading…
Cancel
Save