Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
i_sync_primitive.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <cstdint>
7#include <string_view>
8
9#include "contur/core/error.h"
10#include "contur/core/types.h"
11
12namespace contur {
13
15 enum class SyncLayer : std::uint8_t
16 {
19 };
20
23 {
24 public:
25 virtual ~ISyncPrimitive() = default;
26
30 [[nodiscard]] virtual Result<void> acquire(ProcessId pid) = 0;
31
35 [[nodiscard]] virtual Result<void> release(ProcessId pid) = 0;
36
40 [[nodiscard]] virtual Result<void> tryAcquire(ProcessId pid) = 0;
41
43 [[nodiscard]] virtual std::string_view name() const noexcept = 0;
44
46 [[nodiscard]] virtual SyncLayer layer() const noexcept = 0;
47 };
48
49} // namespace contur
Common interface for synchronization primitives.
virtual ~ISyncPrimitive()=default
virtual SyncLayer layer() const noexcept=0
Layer classification of the primitive.
virtual Result< void > acquire(ProcessId pid)=0
Attempts to acquire the primitive for a process.
virtual Result< void > tryAcquire(ProcessId pid)=0
Attempts non-blocking acquire.
virtual std::string_view name() const noexcept=0
Human-readable primitive name.
virtual Result< void > release(ProcessId pid)=0
Releases the primitive for a process.
A result type that holds either a success value of type T or an ErrorCode.
Definition error.h:104
Error codes and Result<T> type for fallible operations.
Definition block.h:15
std::uint32_t ProcessId
Unique identifier for a process.
Definition types.h:12
SyncLayer
Distinguishes simulated sync resources from kernel-internal locks.
Common type aliases, sentinel constants, and forward declarations used throughout the Contur 2 kernel...