btftoolchain
semaphore.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include "btf_entity_types.h"
6 #include "common.h"
7 
8 namespace btf
9 {
10 
18 class Semaphore
19 {
20  public:
24  enum class Events
25  {
28  assigned,
29 
32  decrement,
33 
36  free,
37 
41  full,
42 
45  increment,
46 
50  lock,
51 
54  lock_used,
55 
58  overfull,
59 
62  queued,
63 
66  released,
67 
70 
73  unlock,
74 
78 
82  used,
83 
87  waiting,
88 
90  unknown
91  };
92 
96  enum class States
97  {
99  free,
100 
102  full,
103 
105  overfull,
106 
108  used,
109 
111  unknown
112  };
113 
118 
125 
131  static std::string eventToString(Events ev);
132 
138  static Events stringToEvent(const std::string& str);
139 
140 private:
142  States state_;
143 };
144 } // namespace btf
Class for Semaphore (SEM) Events (see BTF Specification Chapter 2.3.7).
Definition: semaphore.h:19
static std::string eventToString(Events ev)
Converts the enum Events into string.
Definition: semaphore.cpp:119
ErrorCodes doStateTransition(Events ev)
Transitions the current state depending on the event.
Definition: semaphore.cpp:13
static Events stringToEvent(const std::string &str)
Converts a string into the enum Events.
Definition: semaphore.cpp:158
Events
Possible types of Semaphore events.
Definition: semaphore.h:25
@ unknown
Default value.
@ requestsemaphore
The requestsemaphore event indicates that a process (source) requests a semaphore (target).
States
Possible types of Process states.
Definition: semaphore.h:97
@ used
Semaphore has assigned requests and is still able to handle at least one request.
@ free
Semaphore has no assigned users.
@ unknown
Default state.
@ full
Semaphore has assigned requests and has reached its maximum amount of simultaneous accesses.
@ overfull
Semaphore is locked and at least one request is waiting for the semaphore.
Semaphore(States state=States::unknown)
Constructor of the class Semaphore.
Definition: semaphore.cpp:9
Definition: btf.h:43
ErrorCodes
Error Codes for the btf library.
Definition: common.h:13