Skip to content

An OpenMW mod that lets you play the whole Elder Scrolls III: Morrowind as a top-down isometric game — with full online co-op or MMO modes.

C++
615 B
Raw Blame
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_UPDATEGUARD_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_UPDATEGUARD_H

#include <memory>
#include <mutex>

namespace DetourNavigator
{
    class UpdateGuard
    {
    public:
        explicit UpdateGuard(std::mutex& mutex)
            : mMutex(mutex)
        {
        }

    private:
        std::mutex& mMutex;

        friend struct UnlockUpdateGuard;
    };

    struct UnlockUpdateGuard
    {
        void operator()(UpdateGuard* value) const { value->mMutex.unlock(); }
    };

    using ScopedUpdateGuard = std::unique_ptr<UpdateGuard, UnlockUpdateGuard>;
}

#endif