mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-08-11 22:59:11 +00:00
LambdaTransaction added to ClientProcess
This commit is contained in:
parent
af47ed657f
commit
9d72601f9a
2
hecl/extern/boo
vendored
2
hecl/extern/boo
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 679ba36c4c53e16d749bc88b697ea8316b4f7dae
|
Subproject commit 83f55a54d9abdac3d9f25893a53147798fcce864
|
@ -25,7 +25,8 @@ public:
|
|||||||
enum class Type
|
enum class Type
|
||||||
{
|
{
|
||||||
Buffer,
|
Buffer,
|
||||||
Cook
|
Cook,
|
||||||
|
Lambda
|
||||||
} m_type;
|
} m_type;
|
||||||
bool m_complete = false;
|
bool m_complete = false;
|
||||||
virtual void run(BlenderToken& btok)=0;
|
virtual void run(BlenderToken& btok)=0;
|
||||||
@ -53,6 +54,13 @@ public:
|
|||||||
CookTransaction(ClientProcess& parent, const ProjectPath& path, Database::IDataSpec* spec)
|
CookTransaction(ClientProcess& parent, const ProjectPath& path, Database::IDataSpec* spec)
|
||||||
: Transaction(parent, Type::Cook), m_path(path), m_dataSpec(spec) {}
|
: Transaction(parent, Type::Cook), m_path(path), m_dataSpec(spec) {}
|
||||||
};
|
};
|
||||||
|
struct LambdaTransaction : Transaction
|
||||||
|
{
|
||||||
|
std::function<void(BlenderToken&)> m_func;
|
||||||
|
void run(BlenderToken& btok);
|
||||||
|
LambdaTransaction(ClientProcess& parent, std::function<void(BlenderToken&)>&& func)
|
||||||
|
: Transaction(parent, Type::Lambda), m_func(std::move(func)) {}
|
||||||
|
};
|
||||||
private:
|
private:
|
||||||
std::list<std::unique_ptr<Transaction>> m_pendingQueue;
|
std::list<std::unique_ptr<Transaction>> m_pendingQueue;
|
||||||
std::list<std::unique_ptr<Transaction>> m_completedQueue;
|
std::list<std::unique_ptr<Transaction>> m_completedQueue;
|
||||||
@ -74,6 +82,7 @@ public:
|
|||||||
const BufferTransaction* addBufferTransaction(const hecl::ProjectPath& path, void* target,
|
const BufferTransaction* addBufferTransaction(const hecl::ProjectPath& path, void* target,
|
||||||
size_t maxLen, size_t offset);
|
size_t maxLen, size_t offset);
|
||||||
const CookTransaction* addCookTransaction(const hecl::ProjectPath& path, Database::IDataSpec* spec);
|
const CookTransaction* addCookTransaction(const hecl::ProjectPath& path, Database::IDataSpec* spec);
|
||||||
|
const LambdaTransaction* addLambdaTransaction(std::function<void(BlenderToken&)>&& func);
|
||||||
bool syncCook(const hecl::ProjectPath& path, Database::IDataSpec* spec, BlenderToken& btok);
|
bool syncCook(const hecl::ProjectPath& path, Database::IDataSpec* spec, BlenderToken& btok);
|
||||||
void swapCompletedQueue(std::list<std::unique_ptr<Transaction>>& queue);
|
void swapCompletedQueue(std::list<std::unique_ptr<Transaction>>& queue);
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
@ -46,6 +46,12 @@ void ClientProcess::CookTransaction::run(BlenderToken& btok)
|
|||||||
m_complete = true;
|
m_complete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientProcess::LambdaTransaction::run(BlenderToken& btok)
|
||||||
|
{
|
||||||
|
m_func(btok);
|
||||||
|
m_complete = true;
|
||||||
|
}
|
||||||
|
|
||||||
ClientProcess::Worker::Worker(ClientProcess& proc)
|
ClientProcess::Worker::Worker(ClientProcess& proc)
|
||||||
: m_proc(proc)
|
: m_proc(proc)
|
||||||
{
|
{
|
||||||
@ -66,8 +72,11 @@ void ClientProcess::Worker::proc()
|
|||||||
lk.lock();
|
lk.lock();
|
||||||
m_proc.m_completedQueue.push_back(std::move(trans));
|
m_proc.m_completedQueue.push_back(std::move(trans));
|
||||||
}
|
}
|
||||||
|
if (!m_proc.m_running)
|
||||||
|
break;
|
||||||
m_proc.m_cv.wait(lk);
|
m_proc.m_cv.wait(lk);
|
||||||
}
|
}
|
||||||
|
m_blendTok.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientProcess::ClientProcess(int verbosityLevel)
|
ClientProcess::ClientProcess(int verbosityLevel)
|
||||||
@ -100,6 +109,16 @@ ClientProcess::addCookTransaction(const hecl::ProjectPath& path, Database::IData
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ClientProcess::LambdaTransaction*
|
||||||
|
ClientProcess::addLambdaTransaction(std::function<void(BlenderToken&)>&& func)
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lk(m_mutex);
|
||||||
|
LambdaTransaction* ret = new LambdaTransaction(*this, std::move(func));
|
||||||
|
m_pendingQueue.emplace_back(ret);
|
||||||
|
m_cv.notify_one();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
bool ClientProcess::syncCook(const hecl::ProjectPath& path, Database::IDataSpec* spec, BlenderToken& btok)
|
bool ClientProcess::syncCook(const hecl::ProjectPath& path, Database::IDataSpec* spec, BlenderToken& btok)
|
||||||
{
|
{
|
||||||
if (spec->canCook(path, btok))
|
if (spec->canCook(path, btok))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user