2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
2022-11-17 07:46:07 +00:00
|
|
|
File: AuMutex.Unix.hpp
|
2021-06-27 21:25:29 +00:00
|
|
|
Date: 2021-6-12
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
2022-12-28 23:44:45 +00:00
|
|
|
#include "AuConditionMutex.Unix.hpp"
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
namespace Aurora::Threading::Primitives
|
|
|
|
{
|
2023-08-19 10:41:37 +00:00
|
|
|
struct MutexImpl final : IWaitable
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2023-04-23 18:23:10 +00:00
|
|
|
MutexImpl();
|
|
|
|
~MutexImpl();
|
2021-06-27 21:25:29 +00:00
|
|
|
|
|
|
|
bool HasOSHandle(AuMach &mach) override;
|
|
|
|
bool TryLock() override;
|
|
|
|
bool HasLockImplementation() override;
|
|
|
|
void Lock() override;
|
2023-04-03 07:21:44 +00:00
|
|
|
bool LockMS(AuUInt64 timeout) override;
|
2023-03-12 15:27:28 +00:00
|
|
|
bool LockNS(AuUInt64 timeout) override;
|
2021-06-27 21:25:29 +00:00
|
|
|
void Unlock() override;
|
|
|
|
|
2023-06-26 07:33:47 +00:00
|
|
|
auline bool TryLockNoSpin();
|
2021-06-27 21:25:29 +00:00
|
|
|
private:
|
2022-12-28 23:44:45 +00:00
|
|
|
pthread_cond_t pthreadCv_ {};
|
|
|
|
UnixConditionMutex mutex_;
|
2023-08-11 15:51:42 +00:00
|
|
|
AuUInt32 dwSleeping_ {};
|
2021-06-27 21:25:29 +00:00
|
|
|
};
|
|
|
|
}
|