Tramway SDK
spinlock.h
Go to the documentation of this file.
1// Tramway Drifting and Dungeon Exploration Simulator SDK Runtime
2
3#ifndef TRAM_SDK_TEMPLATES_SPINLOCK_H
4#define TRAM_SDK_TEMPLATES_SPINLOCK_H
5
6#include <atomic>
7
8/* I have no idea how useful this is.
9 */
10
11namespace tram {
12
13class Spinlock {
14public:
15 void Lock() {
16 while (lock.exchange(true));
17 }
18
19 void Unlock() {
20 lock.store(false);
21 }
22private:
23 std::atomic<bool> lock = {false};
24};
25
26}
27
28#endif // TRAM_SDK_TEMPLATES_SPINLOCK_H
Definition: spinlock.h:13
void Lock()
Definition: spinlock.h:15
void Unlock()
Definition: spinlock.h:19
Serialization, i.e.