AuroraRuntime/Include/Aurora/Threading/Primitives/ConditionMutex.hpp

25 lines
686 B
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ConditionMutex.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
namespace Aurora::Threading::Primitives
{
/**
2022-06-29 13:56:59 +00:00
A limited mutex specifically for condition variables.
This should be used with the traditional CV idiom of `lock(), while(cond) { cv.wait() }, unlock()`.
For other use cases, you should use the alternative mutex.
2021-06-27 21:25:29 +00:00
*/
2022-06-01 21:49:38 +00:00
struct IConditionMutex
2021-06-27 21:25:29 +00:00
{
virtual bool TryLock() = 0;
2021-06-27 21:25:29 +00:00
virtual void Lock() = 0;
virtual void Unlock() = 0;
};
AUKN_SHARED_SOO(ConditionMutex, IConditionMutex, kPrimitiveSizeCondMutex);
2021-06-27 21:25:29 +00:00
}