Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
Threading.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef SKYFIRE_PLATFORM_THREADING_H
7#define SKYFIRE_PLATFORM_THREADING_H
8
9#include <mutex>
10#include <shared_mutex>
11
12namespace Skyfire
13{
14 using RecursiveMutex = std::recursive_mutex;
15 using SharedMutex = std::shared_mutex;
16
17 class Mutex
18 {
19 public:
20 void lock() { _mutex.lock(); }
21 bool try_lock() { return _mutex.try_lock(); }
22 void unlock() { _mutex.unlock(); }
23 int acquire() { lock(); return 0; }
24 int tryacquire() { return try_lock() ? 0 : -1; }
25 int release() { unlock(); return 0; }
26
27 private:
28 std::mutex _mutex;
29 };
30
32 {
33 public:
34 void lock() { }
35 bool try_lock() { return true; }
36 void unlock() { }
37 int acquire() { return 0; }
38 int tryacquire() { return 0; }
39 int release() { return 0; }
40 };
41}
42
43#endif
int tryacquire()
Definition Threading.h:24
bool try_lock()
Definition Threading.h:21
void unlock()
Definition Threading.h:22
std::mutex _mutex
Definition Threading.h:28
std::recursive_mutex RecursiveMutex
Definition Threading.h:14
std::shared_mutex SharedMutex
Definition Threading.h:15