Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding user-definable context variable guards #799

Closed
BrodyHiggerson opened this issue Nov 20, 2021 · 1 comment
Closed

Adding user-definable context variable guards #799

BrodyHiggerson opened this issue Nov 20, 2021 · 1 comment
Assignees
Labels
enhancement accepted requests, sooner or later I'll do it

Comments

@BrodyHiggerson
Copy link
Sponsor

BrodyHiggerson commented Nov 20, 2021

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
@skypjack skypjack self-assigned this Nov 20, 2021
@skypjack skypjack added the triage pending issue, PR or whatever label Nov 20, 2021
@skypjack skypjack added enhancement accepted requests, sooner or later I'll do it and removed triage pending issue, PR or whatever labels Jan 30, 2022
@skypjack
Copy link
Owner

Closing this one, let's continue the discussion in #800 (that is, the PR).👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement accepted requests, sooner or later I'll do it
Projects
None yet
Development

No branches or pull requests

2 participants