Closed
Description
Fitting with the "don't pay for what you don't use" concept, I wanted to have an optional way of injecting some kind of lock/guard around context variables in the registry.
I let the user define how the lock is created since, for me, I use a fiber mutex rather than std::mutex, so I need to be able to define it myself. I'm using the lock in the 'leaf nodes' of the function calls since I can't support recursive mutexes and the end result is the same.
(I'm making this issue since the contribution guidelines don't want immediate PRs. The commit I would PR is here: BrodyHiggerson@8870d62)
How I'm using it:
namespace ftl
{
class Fibtex;
} // namespace ftl
namespace detail
{
ftl::Fibtex& GetContextVarFibtex();
} // namespace detail
#ifndef ENTT_REGISTRY_CONTEXT_GUARD
#define ENTT_REGISTRY_CONTEXT_GUARD() \
ftl::LockWrapper wrapper = rtg::Task::LockFibtex(detail::GetContextVarFibtex());\
std::lock_guard guard(wrapper);
#endif // #ifndef ENTT_REGISTRY_CONTEXT_GUARD