mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-09 21:42:13 +00:00
47 lines
799 B
C++
47 lines
799 B
C++
|
#ifndef OPENMW_MWLUA_WORKER_H
|
||
|
#define OPENMW_MWLUA_WORKER_H
|
||
|
|
||
|
#include <condition_variable>
|
||
|
#include <mutex>
|
||
|
#include <optional>
|
||
|
#include <thread>
|
||
|
|
||
|
namespace osgViewer
|
||
|
{
|
||
|
class Viewer;
|
||
|
}
|
||
|
|
||
|
namespace MWLua
|
||
|
{
|
||
|
class LuaManager;
|
||
|
|
||
|
class Worker
|
||
|
{
|
||
|
public:
|
||
|
explicit Worker(LuaManager& manager, osgViewer::Viewer& viewer);
|
||
|
|
||
|
~Worker();
|
||
|
|
||
|
void allowUpdate();
|
||
|
|
||
|
void finishUpdate();
|
||
|
|
||
|
void join();
|
||
|
|
||
|
private:
|
||
|
void update();
|
||
|
|
||
|
void run() noexcept;
|
||
|
|
||
|
LuaManager& mManager;
|
||
|
osgViewer::Viewer& mViewer;
|
||
|
std::mutex mMutex;
|
||
|
std::condition_variable mCV;
|
||
|
bool mUpdateRequest = false;
|
||
|
bool mJoinRequest = false;
|
||
|
std::optional<std::thread> mThread;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
#endif // OPENMW_MWLUA_LUAWORKER_H
|