You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw-tes3mp/apps/openmw/mwphysics/ptrholder.hpp

42 lines
718 B
C++

#ifndef OPENMW_MWPHYSICS_PTRHOLDER_H
#define OPENMW_MWPHYSICS_PTRHOLDER_H
#include <mutex>
#include "../mwworld/ptr.hpp"
namespace MWPhysics
{
class PtrHolder
{
public:
virtual ~PtrHolder() {}
void updatePtr(const MWWorld::Ptr& updated)
{
std::scoped_lock lock(mMutex);
mPtr = updated;
}
MWWorld::Ptr getPtr()
{
std::scoped_lock lock(mMutex);
return mPtr;
}
MWWorld::ConstPtr getPtr() const
{
std::scoped_lock lock(mMutex);
return mPtr;
}
protected:
MWWorld::Ptr mPtr;
private:
mutable std::mutex mMutex;
};
}
#endif