Tramway SDK
spinlock.h
Go to the documentation of this file.
1// TRAMWAY DRIFT AND DUNGEON EXPLORATION SIMULATOR 2022
2// All rights reserved.
3
4#ifndef TRAM_SDK_TEMPLATES_SPINLOCK_H
5#define TRAM_SDK_TEMPLATES_SPINLOCK_H
6
7#include <atomic>
8
9namespace tram {
10
11class Spinlock {
12public:
13 void Lock() {
14 while (lock.exchange(true));
15 }
16
17 void Unlock() {
18 lock.store(false);
19 }
20private:
21 std::atomic<bool> lock = {false};
22};
23
24}
25
26#endif // TRAM_SDK_TEMPLATES_SPINLOCK_H
Definition: spinlock.h:11
void Lock()
Definition: spinlock.h:13
void Unlock()
Definition: spinlock.h:17
Definition: api.h:9