1 /*
2 	SObjectizer 5.
3 */
4 
5 /*!
6 	\file
7 	\brief Various typedefs.
8 */
9 
10 #pragma once
11 
12 #include <atomic>
13 #include <cstdint>
14 
15 // It is necessary that version.hpp will be almost always automatically
16 // included. To do that we include it in that header file because
17 // that file seems to be necessary for all SObjectizer's definintions.
18 #include <so_5/version.hpp>
19 
20 namespace so_5
21 {
22 
23 //! Atomic counter type.
24 using atomic_counter_t = std::atomic_ulong;
25 
26 
27 //! Atomic flag type.
28 using atomic_flag_t = std::atomic_ulong;
29 
30 //! A type for mbox indentifier.
31 using mbox_id_t = unsigned long long;
32 
33 /*!
34  * \brief Default value for null mbox_id.
35  * \since
36  * v.5.5.4.1
37  */
38 inline mbox_id_t
null_mbox_id()39 null_mbox_id()
40 	{
41 		return 0ull;
42 	}
43 
44 /*!
45  * \brief Thread safety indicator.
46  * \since
47  * v.5.4.0
48  */
49 enum class thread_safety_t : std::uint8_t
50 	{
51 		//! Not thread safe.
52 		unsafe = 0,
53 		//! Thread safe.
54 		safe = 1
55 	};
56 
57 /*!
58  * \brief Shorthand for thread unsafety indicator.
59  * \since
60  * v.5.4.0
61  */
62 const thread_safety_t not_thread_safe = thread_safety_t::unsafe;
63 
64 /*!
65  * \brief Shorthand for thread safety indicator.
66  * \since
67  * v.5.4.0
68  */
69 const thread_safety_t thread_safe = thread_safety_t::safe;
70 
71 /*!
72  * \brief Values for dispatcher's work thread activity tracking.
73  */
74 enum class work_thread_activity_tracking_t
75 	{
76 		//! Tracking mode is specified elsewhere.
77 		unspecified,
78 		//! Tracking is disabled.
79 		off,
80 		//! Tracking is enabled.
81 		on
82 	};
83 
84 //
85 // message_mutability_t
86 //
87 /*!
88  * \brief A enum with variants of message mutability or immutability.
89  *
90  * \since
91  * v.5.5.19
92  */
93 enum class message_mutability_t
94 	{
95 		immutable_message,
96 		mutable_message
97 	};
98 
99 //
100 // message_kind_t
101 //
102 /*!
103  * \brief A enum with variants of message kinds.
104  *
105  * \since
106  * v.5.5.23
107  */
108 enum class message_kind_t
109 	{
110 		//! Message is a signal. It means there is no data associated
111 		//! with the message instance.
112 		signal,
113 		//! Message is a classical message. It means that message is
114 		//! an instance of class derived from message_t.
115 		classical_message,
116 		//! Message is an user type message.
117 		user_type_message,
118 		//! Message is an envelope with some other message inside.
119 		enveloped_msg
120 	};
121 
122 //
123 // coop_id_t
124 //
125 /*!
126  * \brief ID of cooperation.
127  *
128  * \since
129  * v.5.6.0
130  */
131 using coop_id_t = std::uint_fast64_t;
132 
133 //
134 // event_handler_kind_t
135 //
136 /*!
137  * \brief Kind of an event handler.
138  *
139  * Since v.5.7.0 event handlers of an agent are devided into the following
140  * categories:
141  *
142  * - final handler. That is an ordinary handler that takes a message and
143  *   handles it. In the case of an enveloped message a final handler should
144  *   take the payload of a message;
145  * - intermediate handler. That is a special handler that doesn't handle
146  *   a message by itself but delegates the handling to some other event
147  *   handler or just suppresses the message. In the case of enveloped message
148  *   an intermediate handler should take the whole envelope.
149  *
150  * \since
151  * v.5.7.0
152  */
153 enum class event_handler_kind_t : char
154 	{
155 		//! Ordinary, final event handler.
156 		//! That event handler should take the payload from an eveloped message.
157 		final_handler,
158 		//! Intermediate event handler.
159 		//! Doesn't handle a message itself but delegates actual processing
160 		//! to some other event handler. Or just skips the processing of
161 		//! the message.
162 		//! That event handler should take the whole envelope.
163 		intermediate_handler
164 	};
165 
166 } /* namespace so_5 */
167 
168