2
3
6
7
8
12#include <so_5/compiler_features.hpp>
13#include <so_5/coop.hpp>
14#include <so_5/coop_listener.hpp>
15#include <so_5/custom_mbox.hpp>
16#include <so_5/declspec.hpp>
17#include <so_5/disp_binder.hpp>
18#include <so_5/environment_infrastructure.hpp>
19#include <so_5/error_logger.hpp>
20#include <so_5/event_exception_logger.hpp>
21#include <so_5/event_queue_hook.hpp>
22#include <so_5/exception.hpp>
23#include <so_5/mbox.hpp>
24#include <so_5/mbox_namespace_name.hpp>
25#include <so_5/mchain.hpp>
26#include <so_5/message.hpp>
27#include <so_5/msg_tracing.hpp>
28#include <so_5/nonempty_name.hpp>
29#include <so_5/queue_locks_defaults_manager.hpp>
30#include <so_5/so_layer.hpp>
31#include <so_5/stop_guard.hpp>
32#include <so_5/subscription_storage_fwd.hpp>
33#include <so_5/timers.hpp>
35#include <so_5/stats/controller.hpp>
36#include <so_5/stats/repository.hpp>
38#include <so_5/disp/one_thread/params.hpp>
39#include <so_5/disp/nef_one_thread/params.hpp>
40#include <so_5/disp/abstract_work_thread.hpp>
48#if defined( SO_5_MSVC
)
50 #pragma warning(disable: 4251
)
93
94
95
96
101
102
103
104
111
112
113
114
117
118
119
120
125
126
127
128
133
134
135
136
142
143
144
148 so_5::timer_thread_factory_t factory );
152
153
154
155
156 template<
class SO_Layer >
160 std::unique_ptr< SO_Layer > layer_ptr )
177 coop_listener_unique_ptr_t coop_listener );
182 event_exception_logger_unique_ptr_t logger );
185
186
187
189
190
191
192
193
194
195
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
226
227
230
231
232
233
234
235
236
237
238
239
240
241
242
251
252
253
254
255
256
265
266
267
268
272 m_error_logger = std::move(logger);
277
278
279
280
281
282
283
284
285
286
287
288
289
293 m_message_delivery_tracer = std::move( tracer );
298
299
300
301
306 m_message_delivery_tracer_filter = std::move( filter );
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
336 m_default_disp_params = std::move(params);
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
366 m_default_disp_params = std::move(params);
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
401 return m_default_disp_params;
405
406
407
408
418
419
420
421
430
431
441
442
452
453
456 queue_locks_defaults_manager_unique_ptr_t manager )
458 m_queue_locks_defaults_manager = std::move(manager);
464
465
469 return m_infrastructure_factory;
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
491 environment_infrastructure_factory_t factory )
493 m_infrastructure_factory = std::move(factory);
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
529 event_queue_hook_unique_ptr_t hook )
531 m_event_queue_hook = std::move(hook);
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
598 so_5::disp::abstract_work_thread_factory_shptr_t factory )
600 m_work_thread_factory = std::move(factory);
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
644 subscription_storage_factory_t factory )
646 m_default_subscription_storage_factory = std::move(factory);
651
652
653
654
655
656
657
658
662 return m_default_subscription_storage_factory;
666
667
668
674 return std::move( m_so_layers );
681 return std::move( m_coop_listener );
688 return std::move( m_event_exception_logger );
695 return std::move( m_timer_thread_factory );
702 return m_error_logger;
706
707
708
709
713 return std::move( m_message_delivery_tracer );
717
718
719
720
724 return std::move( m_message_delivery_tracer_filter );
729
730
734 return std::move( m_queue_locks_defaults_manager );
739
740
744 return std::move( m_event_queue_hook );
749
750
754 return std::move( m_work_thread_factory );
757
758
763
764
765
766
770 const std::type_index & type,
772 layer_unique_ptr_t layer_ptr );
787
788
789
790
794
795
796
797
798
799
803
804
805
806
810
811
812
813
817
818
819
820
824
825
826
827
831
832
833
834
838
839
840
841
845
846
847
848
852
853
854
855
856
857
858
859
863
864
865
866
867
868
869
870
874
875
876
877
878
879
880
881
882
883
884
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
961
962
978
979
980
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1184 const std::function< mbox_t() > & mbox_factory );
1187
1188
1191
1192
1193
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1240
1241
1244
1245
1246
1251 event_exception_logger_unique_ptr_t logger );
1253
1254
1257
1258
1259
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1307 disp_binder_shptr_t disp_binder );
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1366 disp_binder_shptr_t disp_binder );
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1445 std::unique_ptr< A > agent )
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1472 std::unique_ptr< A > agent,
1473 disp_binder_shptr_t disp_binder )
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1560 int reason )
noexcept
1562 auto coop_shptr = low_level_api::to_shptr_noexcept( coop );
1564 coop_shptr->deregister( reason );
1567
1568
1571
1572
1573
1577 template<
class SO_Layer >
1582 "SO_Layer must be derived from so_layer_t class" );
1589 template<
class SO_Layer >
1598 "layer does not exist" );
1604 template<
class SO_Layer >
1607 std::unique_ptr< SO_Layer > layer_ptr )
1614
1615
1618
1619
1620
1628
1629
1630
1631
1632
1638
1639
1640
1644
1645
1648
1649
1650
1651
1652
1653
1654
1658 const std::exception & event_exception,
1663
1664
1665
1666
1667
1668
1669
1674
1675
1676
1677
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707 template<
class Agent,
typename... Args >
1716
1717
1718
1719
1724
1725
1726
1727
1732
1733
1734
1735
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774 template<
typename... Args >
1779
1780
1781
1782
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1801
1802
1803
1804
1805
1806
1807
1808
1814
1815
1816
1817
1818
1819
1820
1821
1829
1830
1831
1832
1833
1834
1835
1836
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853 template<
typename Lambda >
1864
1865
1866
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1928 stop_guard_shptr_t guard,
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1973 stop_guard_shptr_t guard );
1975
1976
1979
1980
1981
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2029
2030
2036 const std::type_index & type )
const;
2041 const std::type_index & type,
2042 const layer_ref_t & layer );
2047 const std::type_index & type );
2051
2052
2063
2064
2065
2067
2068
2069
2070
2071
2076
2077
2082
2083
2084
2085
2089
2090
2097
2098
2099
2100
2109 template<
typename Lambda >
2112 disp_binder_shptr_t binder,
2115 const auto coop_maker = [
this, b = std::move(binder)] {
2117 return m_env.make_coop( m_parent, std::move(b) );
2119 return m_env.make_coop( std::move(b) );
2122 auto coop = coop_maker();
2124 using return_type = std::invoke_result_t<Lambda, so_5::coop_t &>;
2126 if constexpr( std::is_void_v<return_type> )
2129 m_env.register_coop( std::move( coop ) );
2131 else if constexpr( std::is_reference_v<return_type> )
2133 auto && ret_val = lambda( *coop );
2134 m_env.register_coop( std::move( coop ) );
2136 return std::forward<
decltype(ret_val)>(ret_val);
2140 auto ret_val = lambda( *coop );
2141 m_env.register_coop( std::move( coop ) );
2161
2162
2163
2164 template<
typename L >
2168 return build_and_register_coop(
2169 m_env.so_make_default_disp_binder(),
2170 std::forward< L >( lambda ) );
2174
2175
2176
2177 template<
typename L >
2181 return build_and_register_coop(
2182 std::move( binder ),
2183 std::forward< L >( lambda ) );
2189template<
typename... Args >
2194 return helper.introduce( std::forward< Args >( args )... );
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219template<
typename... Args >
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258template<
typename... Args >
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298template<
typename... Args >
2306 return details::introduce_coop_helper_t{
2307 owner.so_environment(),
2309 }.introduce( std::forward< Args >(args)... );
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339template<
typename... Args >
2347 return details::introduce_coop_helper_t{
2348 low_level_api::to_shptr(parent)->environment(),
2350 }.introduce( std::forward< Args >(args)... );
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2381 return env.so_make_default_disp_binder();
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2402 const std::type_index & subscription_type,
2406 const mbox_t & mbox,
2408 std::chrono::steady_clock::duration pause,
2411
2412
2413
2414 std::chrono::steady_clock::duration period )
2416 return mbox->environment().so_schedule_timer(
2417 schedule_timer_params_t{
2418 std::cref(subscription_type),
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2440 const std::type_index & subscription_type,
2444 const mbox_t & mbox,
2446 std::chrono::steady_clock::duration pause )
2448 return mbox->environment().so_single_timer(
2449 single_timer_params_t{
2450 std::cref(subscription_type),
2460#if defined( SO_5_MSVC
)
2461 #pragma warning(pop)
virtual void unsubscribe_event_handler(const std::type_index &type_index, abstract_message_sink_t &subscriber) noexcept=0
Remove all message handlers.
virtual void subscribe_event_handler(const std::type_index &type_index, abstract_message_sink_t &subscriber)=0
Add the message handler.
virtual so_5::environment_t & environment() const noexcept=0
SObjectizer Environment for which the mbox is created.
abstract_message_box_t()=default
abstract_message_box_t(const abstract_message_box_t &)=delete
virtual void drop_delivery_filter(const std::type_index &msg_type, abstract_message_sink_t &subscriber) noexcept=0
Removes delivery filter for message type and subscriber.
virtual void set_delivery_filter(const std::type_index &msg_type, const delivery_filter_t &filter, abstract_message_sink_t &subscriber)=0
Set a delivery filter for message type and subscriber.
virtual ~abstract_message_box_t() noexcept=default
virtual mbox_id_t id() const =0
Unique ID of this mbox.
virtual std::string query_name() const =0
Get the mbox name.
abstract_message_box_t & operator=(abstract_message_box_t &&)=delete
virtual void do_deliver_message(message_delivery_mode_t delivery_mode, const std::type_index &msg_type, const message_ref_t &message, unsigned int redirection_deep)=0
Deliver message for all subscribers with respect to message limits.
abstract_message_box_t & operator=(const abstract_message_box_t &)=delete
virtual mbox_type_t type() const =0
Get the type of message box.
abstract_message_box_t(abstract_message_box_t &&)=delete
Interface for message sink.
abstract_message_sink_t & operator=(const abstract_message_sink_t &)=default
abstract_message_sink_t(const abstract_message_sink_t &)=default
abstract_message_sink_t()=default
abstract_message_sink_t(abstract_message_sink_t &&) noexcept=default
abstract_message_sink_t & operator=(abstract_message_sink_t &&) noexcept=default
static bool special_sink_ptr_compare(const abstract_message_sink_t *a, const abstract_message_sink_t *b) noexcept
virtual void push_event(mbox_id_t mbox_id, message_delivery_mode_t delivery_mode, const std::type_index &msg_type, const message_ref_t &message, unsigned int redirection_deep, const message_limit::impl::action_msg_tracer_t *tracer)=0
Get a message and push it to the appropriate destination.
virtual priority_t sink_priority() const noexcept=0
Get the priority for the message sink.
virtual environment_t & environment() const noexcept=0
virtual ~abstract_message_sink_t() noexcept=default
Interface for holders of message_sink instances.
abstract_sink_owner_t()=default
virtual const abstract_message_sink_t & sink() const noexcept=0
Get a const reference to the underlying message sink.
virtual abstract_message_sink_t & sink() noexcept=0
Get a reference to the underlying message sink.
virtual ~abstract_sink_owner_t() noexcept=default
A context for agent construction and tuning.
environment_t * m_env
SObjectizer Environment to work in.
agent_context_t(environment_t &env, agent_tuning_options_t options)
const agent_tuning_options_t & options() const
Read-only access to agent options.
agent_context_t(environment_t &env)
Constructor for the case when only environment available.
environment_t & environment() const
Access to SObjectizer Environment.
agent_tuning_options_t & options()
Read-Write access to agent options.
friend void swap(so_5::agent_context_t &a, so_5::agent_context_t &b) noexcept
Swap operation.
agent_tuning_options_t m_options
Options for agent tuning.
environment_t & env() const
Access to SObjectizer Environment.
Helper class for holding agent's identity (name or pointer).
std::string_view actual_name() const noexcept
Attempt to get an agent name.
friend std::ostream & operator<<(std::ostream &to, const agent_identity_t &what)
std::string to_string() const
Transform identity into a string.
agent_identity_t(std::string_view name) noexcept
Initializing constructor for case when agent has a user specified name.
bool has_actual_name() const noexcept
Does agent have an actual name?
value_t m_value
Agent's identity.
agent_identity_t(const agent_t *pointer) noexcept
Initializing constructor for case when agent has no user specified name.
Interface of the agent state listener.
virtual ~agent_state_listener_t() noexcept=default
agent_state_listener_t(const agent_state_listener_t &)=delete
agent_state_listener_t & operator=(const agent_state_listener_t &)=delete
virtual void changed(agent_t &agent, const state_t &state) noexcept=0
Hook method for state changes.
agent_state_listener_t()=default
Type for holding information necessary for handling time limits for agent states.
~state_time_limit_handling_data_t()
bool is_defined() const noexcept
Is the data for handling time limits defined?
state_time_limit_handling_data_t()
mbox_t timeout_mbox() const noexcept
void make_defined(mbox_t timeout_mbox)
void so_subscribe_deadletter_handler(const so_5::mbox_t &mbox, Event_Handler &&handler, thread_safety_t thread_safety=thread_safety_t::unsafe)
Create a subscription for deadletter handler for a specific message from a specific mbox.
static demand_handler_pfn_t get_demand_handler_on_start_ptr() noexcept
impl::state_listener_controller_t m_state_listener_controller
State listeners controller.
decltype(auto) so_low_level_exec_as_event_handler(Lambda &&lambda) noexcept(noexcept(lambda()))
Helper method that allows to run a block of code as non-thread-safe event handler.
static void process_enveloped_msg(current_thread_id_t working_thread_id, execution_demand_t &d, const impl::event_handler_data_t *handler_data)
Actual implementation of enveloped message handling.
std::unique_ptr< impl::sinks_storage_t > m_message_sinks
Holder of message sinks for that agent.
void do_change_agent_state(const state_t &state_to_be_set)
Perform actual operations related to state switch.
void so_drop_delivery_filter(const mbox_t &mbox) noexcept
Drop a delivery filter.
void so_initiate_agent_definition()
A correct initiation of so_define_agent method call.
const agent_t * self_ptr() const
Get the raw pointer of itself.
void evt_state_time_limit(mhood_t< so_5::details::msg_state_timeout >)
Special event handler to process state time limits.
so_5::current_thread_id_t m_working_thread_id
Working thread id.
default_rw_spinlock_t m_event_queue_lock
Event queue operation protector.
const name_for_agent_t m_name
Optional name for the agent.
static const impl::event_handler_data_t * find_deadletter_handler(execution_demand_t &demand)
Search for event handler between deadletter handlers.
static demand_handler_pfn_t get_demand_handler_on_message_ptr() noexcept
bool is_agent_deactivated() const noexcept
Is agent already deactivated.
void so_switch_to_awaiting_deregistration_state()
Switching agent to special state in case of unhandled exception.
const state_t & so_current_state() const
Access to the current agent state.
static void process_message(current_thread_id_t working_thread_id, execution_demand_t &d, thread_safety_t thread_safety, event_handler_method_t method)
Actual implementation of message handling.
agent_ref_t create_ref()
Make an agent reference.
void so_drop_deadletter_handler(const so_5::mbox_t &mbox)
Drops the subscription for deadletter handler.
bool so_is_active_state(const state_t &state_to_check) const noexcept
Is a state activated?
void ensure_operation_is_on_working_thread(const char *operation_name) const
Enables operation only if it is performed on agent's working thread.
static constexpr const state_t::history_t deep_history
Short alias for so_5::state_t::history_t::deep.
bool so_was_defined() const
Is method define_agent already called?
agent_status_t
Enumeration of possible agent statuses.
@ shutdown_with_skipping_pending_demands
Agent was shutdown and all pending demands have to be skipped.
@ defined
Agent is defined.
@ state_switch_in_progress
State switch operation is in progress.
void destroy_all_subscriptions_and_filters() noexcept
Destroy all agent's subscriptions.
void shutdown_agent() noexcept
Agent shutdown deriver.
void ensure_binding_finished()
Ensures that all agents from cooperation are bound to dispatchers.
coop_t * m_agent_coop
Agent is belong to this cooperation.
disp_binder_shptr_t so_this_agent_disp_binder() const
Returns the dispatcher binder that is used for binding this agent.
agent_status_t m_current_status
Current agent status.
event_queue_t * m_event_queue
A pointer to event_queue.
void so_set_delivery_filter(const mbox_t &mbox, Lambda &&lambda)
Set a delivery filter.
virtual void so_define_agent()
Hook on define agent for SObjectizer.
void drop_all_delivery_filters() noexcept
Drops all delivery filters.
disp_binder_shptr_t m_disp_binder
Binder for this agent.
bool do_check_subscription_presence(const mbox_t &mbox, const std::type_index &msg_type, const state_t &target_state) const noexcept
Check the presence of a subscription.
void do_state_switch(const state_t &state_to_be_set) noexcept
Actual action for switching agent state.
std::unique_ptr< impl::delivery_filter_storage_t > m_delivery_filters
Delivery filters for that agents.
void return_to_default_state_if_possible() noexcept
Return agent to the default state.
subscription_bind_t so_subscribe_self()
Initiate subscription to agent's direct mbox.
agent_t(environment_t &env)
Constructor.
void do_set_delivery_filter(const mbox_t &mbox, const std::type_index &msg_type, delivery_filter_unique_ptr_t filter)
Set a delivery filter.
static void call_push_event(agent_t &agent, const message_limit::control_block_t *limit, mbox_id_t mbox_id, const std::type_index &msg_type, const message_ref_t &message)
Push an event to the agent's event queue.
mbox_t so_make_new_direct_mbox()
Create a new direct mbox for that agent.
static execution_hint_t so_create_execution_hint(execution_demand_t &demand)
Create execution hint for the specified demand.
void so_change_state(const state_t &new_state)
Change the current state of the agent.
void push_event(const message_limit::control_block_t *limit, mbox_id_t mbox_id, const std::type_index &msg_type, const message_ref_t &message)
Push event into the event queue.
static custom_direct_mbox_factory_t custom_direct_mbox_factory(Lambda &&lambda)
Helper for creation a custom direct mbox factory.
coop_handle_t so_coop() const
Get a handle of agent's coop.
void so_deregister_agent_coop_normally()
A helper method for deregistering agent's coop in case of normal deregistration.
void do_drop_delivery_filter(const mbox_t &mbox, const std::type_index &msg_type) noexcept
Drop a delivery filter.
virtual exception_reaction_t so_exception_reaction() const noexcept
A reaction from SObjectizer to an exception from agent's event.
void so_deactivate_agent()
Deactivate the agent.
disp_binder_shptr_t so_this_coop_disp_binder() const
Returns the dispatcher binder that is used as the default binder for the agent's coop.
abstract_message_sink_t & detect_sink_for_message_type(const std::type_index &msg_type)
Helper function that returns a message sink to be used for subscriptions for specified message type.
const demands_handling_on_dereg_t m_demands_handling_on_dereg
What to do with pending demands on deregistration.
static void demand_handler_on_message(current_thread_id_t working_thread_id, execution_demand_t &d)
Calls event handler for message.
static constexpr const state_t::history_t shallow_history
Short alias for so_5::state_t::history_t::shallow.
void so_drop_all_subscriptions_and_filters()
Dropping all agents subscriptions and filters.
virtual void so_evt_finish()
Hook of agent finish in SObjectizer.
static demand_handler_pfn_t get_demand_handler_on_finish_ptr() noexcept
void so_add_nondestroyable_listener(agent_state_listener_t &state_listener)
Add a state listener to the agent.
static const impl::event_handler_data_t * handler_finder_msg_tracing_disabled(execution_demand_t &demand, const char *context_marker)
Handler finder for the case when message delivery tracing is disabled.
const state_t * m_current_state_ptr
Current agent state.
const mbox_t m_direct_mbox
A direct mbox for the agent.
bool so_has_deadletter_handler(const so_5::mbox_t &mbox) const noexcept
Checks the presence of deadletter handler for a message of a specific type from a specific mbox.
const priority_t m_priority
Priority of the agent.
agent_identity_t so_agent_name() const noexcept
Get an optional name of the agent.
static const impl::event_handler_data_t * handler_finder_msg_tracing_enabled(execution_demand_t &demand, const char *context_marker)
Handler finder for the case when message delivery tracing is enabled.
void bind_to_coop(coop_t &coop)
Bind agent to the cooperation.
static const impl::event_handler_data_t * find_event_handler_for_current_state(execution_demand_t &demand)
Actual search for event handler with respect to parent-child relationship between agent states.
static void demand_handler_on_start(current_thread_id_t working_thread_id, execution_demand_t &d)
Calls so_evt_start method for agent.
const mbox_t & so_direct_mbox() const
Get the agent's direct mbox.
impl::subscription_storage_unique_ptr_t m_subscriptions
All agent's subscriptions.
void so_destroy_deadletter_subscription(const mbox_t &mbox, const std::type_index &msg_type)
Destroy a subscription for a deadletter handler.
static void demand_handler_on_finish(current_thread_id_t working_thread_id, execution_demand_t &d)
Calls so_evt_finish method for agent.
bool do_check_deadletter_presence(const mbox_t &mbox, const std::type_index &msg_type) const noexcept
Check the presence of a deadletter handler.
void do_drop_subscription_for_all_states(const mbox_t &mbox, const std::type_index &msg_type)
Remove subscription for all states.
agent_t(context_t ctx)
Constructor which simplifies agent construction with or without agent's tuning options.
static agent_tuning_options_t tuning_options()
Create tuning options object with default values.
void so_add_destroyable_listener(agent_state_listener_unique_ptr_t state_listener)
Add a state listener to the agent.
environment_t & so_environment() const noexcept
Access to the SObjectizer Environment which this agent is belong.
priority_t so_priority() const noexcept
Get the priority of the agent.
const state_t & so_default_state() const
Access to the agent's default state.
subscription_bind_t so_subscribe(const mbox_t &mbox_ref)
Initiate subscription.
state_time_limit_handling_data_t m_state_time_limit_handling_data
Data that is necessary for handling time limits of agent's states.
void so_bind_to_dispatcher(event_queue_t &queue) noexcept
Binding agent to the dispatcher.
void so_destroy_event_subscription(const mbox_t &mbox, const std::type_index &subscription_type, const state_t &target_state)
Destroy event subscription.
void so_set_delivery_filter_for_mutable_msg(const mbox_t &mbox, Lambda &&lambda)
Set a delivery filter for a mutable message.
environment_t & m_env
SObjectizer Environment for which the agent is belong.
void so_deregister_agent_coop(int dereg_reason)
A helper method for deregistering agent's coop.
void do_drop_subscription(const mbox_t &mbox, const std::type_index &msg_type, const state_t &target_state)
Remove subscription for the state specified.
agent_t(environment_t &env, agent_tuning_options_t tuning_options)
Constructor which allows specification of agent's tuning options.
handler_finder_t m_handler_finder
Function for searching event handler.
void define_state_time_limit_handling_data_if_needed()
Initialize data for handling time limit of agent's states.
virtual void so_evt_start()
Hook on agent start inside SObjectizer.
static demand_handler_pfn_t get_demand_handler_on_enveloped_msg_ptr() noexcept
void so_create_event_subscription(const mbox_t &mbox_ref, std::type_index type_index, const state_t &target_state, const event_handler_method_t &method, thread_safety_t thread_safety, event_handler_kind_t handler_kind)
Create a subscription for an event.
void so_set_delivery_filter(const mbox_t &mbox, delivery_filter_unique_ptr_t filter)
Set a delivery filter.
static void demand_handler_on_enveloped_msg(current_thread_id_t working_thread_id, execution_demand_t &d)
Handles the enveloped message.
A collector for agent tuning options.
name_for_agent_t m_agent_name
Optional name for an agent.
so_5::priority_t query_priority() const noexcept
Get priority value.
bool m_is_user_provided_subscription_storage_factory
Does a user provide a specific subscription_storage_factory?
agent_tuning_options_t & agent_name(name_for_agent_t name)
Set a name for agent.
subscription_storage_factory_t m_subscription_storage_factory
name_for_agent_t giveout_agent_name() noexcept
Gives away the name for an agent.
friend void swap(so_5::agent_tuning_options_t &a, so_5::agent_tuning_options_t &b) noexcept
message_limit::description_container_t m_message_limits
demands_handling_on_dereg_t m_demands_handling_on_dereg
What to do with pending demands on deregistration.
bool has_agent_name() const noexcept
Does a name specified for an agent?
agent_tuning_options_t()=default
agent_tuning_options_t & custom_direct_mbox_factory(custom_direct_mbox_factory_t factory)
Set custom direct mbox factory.
const custom_direct_mbox_factory_t & query_custom_direct_mbox_factory() const noexcept
Get a reference to custom direct mbox factory.
so_5::priority_t m_priority
Priority for agent.
bool is_user_provided_subscription_storage_factory() const noexcept
Does a user provide a specific subscription_storage_factory?
static subscription_storage_factory_t default_subscription_storage_factory()
Default subscription storage factory.
const subscription_storage_factory_t & query_subscription_storage_factory() const noexcept
agent_tuning_options_t & message_limits(Args &&... args)
demands_handling_on_dereg_t demands_handling_on_dereg() const noexcept
agent_tuning_options_t & subscription_storage_factory(subscription_storage_factory_t factory) noexcept(noexcept(std::declval< subscription_storage_factory_t & >()=std::move(factory)))
Set factory for subscription storage creation.
message_limit::description_container_t giveout_message_limits()
agent_tuning_options_t & demands_handling_on_dereg(demands_handling_on_dereg_t handling_mode)
Set mode of handling pending demands on deregistration.
agent_tuning_options_t & priority(so_5::priority_t v)
Set priority for agent.
custom_direct_mbox_factory_t m_custom_direct_mbox_factory
Optional factory for custom direct mboxes.
The base class for the object with a reference counting.
atomic_refcounted_t(const atomic_refcounted_t &)=delete
unsigned long dec_ref_count() noexcept
Decrement reference count.
atomic_refcounted_t() noexcept
Default constructor.
atomic_counter_t m_ref_counter
Object reference count.
void inc_ref_count() noexcept
Increments reference count.
~atomic_refcounted_t() noexcept=default
Destructor.
atomic_refcounted_t & operator=(const atomic_refcounted_t &)=delete
It's a kind of strong typedef for coop's deregistration reason.
Type of smart handle for a cooperation.
friend bool operator>=(const coop_handle_t &a, const coop_handle_t &b) noexcept
static constexpr const coop_id_t invalid_coop_id
friend bool operator<(const coop_handle_t &a, const coop_handle_t &b) noexcept
bool operator!() const noexcept
Is this non-empty handle?
friend bool operator==(const coop_handle_t &a, const coop_handle_t &b) noexcept
friend bool operator!=(const coop_handle_t &a, const coop_handle_t &b) noexcept
operator bool() const noexcept
Is this handle empty?
coop_handle_t(coop_id_t id, std::shared_ptr< coop_t > coop)
Initializing constructor.
friend bool operator<=(const coop_handle_t &a, const coop_handle_t &b) noexcept
coop_id_t m_id
ID of cooperation.
auto id() const noexcept
Get the ID of the coop.
friend std::ostream & operator<<(std::ostream &to, const coop_handle_t &what)
A tool for dumping coop_handle to ostream.
std::weak_ptr< coop_t > m_coop
Pointer for cooperation.
friend bool operator>(const coop_handle_t &a, const coop_handle_t &b) noexcept
exception_reaction_t exception_reaction() const noexcept
Get the current exception rection flag for that cooperation.
coop_handle_t handle() noexcept
Get handle for this coop.
A special type that plays role of unique_ptr for coop.
Interface for creator of new mbox in OOP style.
An interface of delivery filter object.
delivery_filter_t(delivery_filter_t &&)=delete
virtual bool check(const abstract_message_sink_t &receiver, message_t &msg) const noexcept=0
Checker for a message instance.
delivery_filter_t & operator=(delivery_filter_t &&)=delete
delivery_filter_t(const delivery_filter_t &)=delete
virtual ~delivery_filter_t() noexcept=default
delivery_filter_t()=default
delivery_filter_t & operator=(const delivery_filter_t &)=delete
Helper class for building and registering new cooperation.
decltype(auto) build_and_register_coop(disp_binder_shptr_t binder, Lambda &&lambda)
introduce_coop_helper_t(environment_t &env)
Constructor for the case of creation a cooperation without parent.
coop_handle_t m_parent
Optional parent coop.
introduce_coop_helper_t(environment_t &env, coop_handle_t parent)
Constructor for the case of creation a cooperation with parent.
decltype(auto) introduce(disp_binder_shptr_t binder, L &&lambda)
environment_t & m_env
Environment for creation of cooperation.
decltype(auto) introduce(L &&lambda)
Basic part of message_holder implementations.
basic_message_holder_impl_t(intrusive_ptr_t< Envelope > msg) noexcept
basic_message_holder_impl_t() noexcept=default
operator bool() const noexcept
Check for the non-emptiness of message_holder.
intrusive_ptr_t< Envelope > m_msg
Message instance.
bool operator!() const noexcept
Check for the emptiness of message_holder.
bool empty() const noexcept
Check for the emptiness of message_holder.
void reset() noexcept
Drops to pointer to the message instance.
An of mixin with getters for message_holder.
Return_Type & operator*() const noexcept
Get a reference to the message inside message_holder.
Return_Type * get() const noexcept
Get a pointer to the message inside message_holder.
Return_Type * operator->() const noexcept
Get a pointer to the message inside message_holder.
A part of implementation of message_holder to be used for shared ownership of message instances.
intrusive_ptr_t< Envelope > make_reference() const noexcept
Make an another reference to the message.
A part of implementation of message_holder to be used for unique ownership of message instances.
unique_message_holder_impl_t(const unique_message_holder_impl_t &)=delete
unique_message_holder_impl_t & operator=(const unique_message_holder_impl_t &)=delete
intrusive_ptr_t< Envelope > make_reference() noexcept
Extracts the smart pointer to the message.
unique_message_holder_impl_t & operator=(unique_message_holder_impl_t &&) noexcept=default
unique_message_holder_impl_t(unique_message_holder_impl_t &&)=default
mhood_base_t(const mhood_base_t &)=delete
payload_type * get() const noexcept
Access to the message.
message_holder_t< M, Ownership > make_holder() noexcept
Create a holder for this message.
mhood_base_t & operator=(const mhood_base_t &)=delete
payload_type & operator*() noexcept
Access to the message.
mhood_base_t(mhood_base_t &&other) noexcept
intrusive_ptr_t< envelope_type > make_reference() noexcept
Create a smart pointer for the message envelope.
mhood_base_t & operator=(mhood_base_t &&other) noexcept
mhood_base_t(message_ref_t &mf) noexcept
payload_type * operator->() noexcept
Access to the message via pointer.
friend void swap(mhood_base_t &a, mhood_base_t &b) noexcept
message_holder_t< M, Ownership > make_holder() const noexcept
Create a holder for this message.
const payload_type & operator*() const noexcept
Access to the message.
mhood_base_t(message_ref_t &mf) noexcept
intrusive_ptr_t< envelope_type > make_reference() const noexcept
Create a smart pointer for the message envelope.
const payload_type * get() const noexcept
Access to the message.
const payload_type * operator->() const noexcept
Access to the message via pointer.
mhood_base_t(message_ref_t &)
mhood_base_t(message_ref_t &)
mhood_base_t(mhood_base_t &&other) noexcept
payload_type & operator*() noexcept
Access to the message.
mhood_base_t & operator=(const mhood_base_t &)=delete
intrusive_ptr_t< envelope_type > make_reference() noexcept
Create a smart pointer for the message envelope.
envelope_type * m_envelope
mhood_base_t(const mhood_base_t &)=delete
mhood_base_t(message_ref_t &mf) noexcept
payload_type * operator->() noexcept
Access to the message via pointer.
message_holder_t< M, Ownership > make_holder() noexcept
Create a holder for this message.
mhood_base_t & operator=(mhood_base_t &&other) noexcept
payload_type * get() noexcept
Access to the message.
friend void swap(mhood_base_t &a, mhood_base_t &b) noexcept
mhood_base_t(message_ref_t &mf) noexcept
const payload_type * m_payload
const payload_type * get() const noexcept
Access to the message.
const payload_type & operator*() const noexcept
Access to the message.
envelope_type * m_envelope
message_holder_t< M, Ownership > make_holder() const noexcept
Create a holder for this message.
const payload_type * operator->() const noexcept
Access to the message via pointer.
intrusive_ptr_t< envelope_type > make_reference() const noexcept
Create a smart pointer for the message envelope.
A type to be used as a base for mhood_t implementation.
Helper template class for do rollback actions automatically in the destructor.
Helper class for scope exit implementation.
Alias for namespace with traits of event queue.
Alias for namespace with traits of event queue.
Interface for dispatcher binders.
disp_binder_t(const disp_binder_t &)=delete
virtual void bind(agent_t &agent) noexcept=0
Bind agent to dispatcher.
virtual void unbind(agent_t &agent) noexcept=0
Unbind agent from dispatcher.
disp_binder_t & operator=(const disp_binder_t &)=delete
disp_binder_t(disp_binder_t &&)=delete
virtual void preallocate_resources(agent_t &agent)=0
Allocate resources in dispatcher for new agent.
disp_binder_t & operator=(disp_binder_t &&)=delete
virtual void undo_preallocation(agent_t &agent) noexcept=0
Undo resources allocation.
virtual ~disp_binder_t() noexcept=default
An interface of envelope with some message/signal inside.
virtual ~envelope_t() override=default
envelope_t(const envelope_t &)=default
envelope_t & operator=(envelope_t &&) noexcept=default
envelope_t & operator=(const envelope_t &)=default
kind_t so5_message_kind() const noexcept override
Detect the kind of the message.
virtual void access_hook(access_context_t context, handler_invoker_t &invoker) noexcept=0
envelope_t(envelope_t &&)=default
An extended version of handling_context which can be used for calling event handler.
handler_invoker_t(const handler_invoker_t &)=default
handler_invoker_t(handler_invoker_t &&)=default
~handler_invoker_t()=default
handler_invoker_t & operator=(const handler_invoker_t &)=default
handler_invoker_t & operator=(handler_invoker_t &&) noexcept=default
virtual void invoke(const payload_info_t &payload) noexcept=0
Call an actual handler for the enveloped message/signal.
handler_invoker_t()=default
An implementation of handler_invoker interface.
An information about payload inside envelope.
message_ref_t m_message
Actual enveloped message.
message_ref_t & message() const noexcept
payload_info_t(message_ref_t message)
Initializing constructor.
Parameters for the SObjectizer Environment initialization.
event_queue_hook_unique_ptr_t m_event_queue_hook
An event_queue_hook object.
layer_map_t m_so_layers
Additional layers.
so_5::disp::abstract_work_thread_factory_shptr_t so5_giveout_work_thread_factory()
Take out work_thread_factory object.
environment_infrastructure_factory_t m_infrastructure_factory
A factory for environment infrastructure entity.
environment_params_t & event_exception_logger(event_exception_logger_unique_ptr_t logger)
Set exception logger object.
bool m_autoshutdown_disabled
Is autoshutdown when there is no more cooperation disabled?
queue_locks_defaults_manager_unique_ptr_t so5_giveout_queue_locks_defaults_manager()
Take out queue locks defaults manager.
environment_params_t & default_subscription_storage_factory(subscription_storage_factory_t factory)
Set subscription storage factory to be used by default.
environment_params_t & infrastructure_factory(environment_infrastructure_factory_t factory)
Set new environment infrastructure factory.
environment_params_t & work_thread_factory(so_5::disp::abstract_work_thread_factory_shptr_t factory)
Set work thread factory to be used by default.
environment_params_t & default_disp_params(so_5::disp::nef_one_thread::disp_params_t params)
Set parameters for a case when nef_one_thread-disp must be used as the default dispatcher.
default_disp_params_t m_default_disp_params
Parameters for the default dispatcher.
void add_layer(const std::type_index &type, layer_unique_ptr_t layer_ptr)
Add an additional layer.
bool autoshutdown_disabled() const
Is autoshutdown disabled?
coop_listener_unique_ptr_t so5_giveout_coop_listener()
Get cooperation listener.
environment_params_t & turn_work_thread_activity_tracking_off()
Helper for turning work thread activity tracking off.
environment_params_t & disable_autoshutdown()
Do not shutdown SO Environment when it is becomes empty.
so_5::msg_tracing::tracer_unique_ptr_t so5_giveout_message_delivery_tracer()
Get message delivery tracer for the environment.
environment_params_t & message_delivery_tracer(so_5::msg_tracing::tracer_unique_ptr_t tracer)
Set message delivery tracer for the environment.
environment_params_t & queue_locks_defaults_manager(queue_locks_defaults_manager_unique_ptr_t manager)
Set manager for queue locks defaults.
environment_params_t & error_logger(error_logger_shptr_t logger)
Set error logger for the environment.
environment_params_t & default_disp_params(so_5::disp::one_thread::disp_params_t params)
Set parameters for a case when one_thread-disp must be used as the default dispatcher.
environment_params_t & work_thread_activity_tracking(work_thread_activity_tracking_t flag)
Set activity tracking flag for the whole SObjectizer Environment.
void event_queue_hook(event_queue_hook_unique_ptr_t hook)
Set event_queue_hook object.
environment_params_t & add_layer(std::unique_ptr< SO_Layer > layer_ptr)
Add an additional layer to the SObjectizer Environment.
so_5::msg_tracing::filter_shptr_t so5_giveout_message_delivery_tracer_filter()
Get message delivery tracer filter for the environment.
queue_locks_defaults_manager_unique_ptr_t m_queue_locks_defaults_manager
Manager for defaults of queue locks.
environment_params_t(environment_params_t &&other)
Move constructor.
so_5::timer_thread_factory_t so5_giveout_timer_thread_factory()
Get the timer_thread factory.
const environment_infrastructure_factory_t & infrastructure_factory() const
Get the current environment infrastructure factory.
friend SO_5_FUNC void swap(environment_params_t &a, environment_params_t &b) noexcept
Swap operation.
environment_params_t & coop_listener(coop_listener_unique_ptr_t coop_listener)
Set cooperation listener object.
environment_params_t & turn_work_thread_activity_tracking_on()
Helper for turning work thread activity tracking on.
layer_map_t so5_giveout_layers_map()
Get map of default SObjectizer's layers.
so_5::msg_tracing::tracer_unique_ptr_t m_message_delivery_tracer
Tracer for message delivery.
exception_reaction_t exception_reaction() const noexcept
Get exception reaction flag value.
error_logger_shptr_t m_error_logger
Error logger for the environment.
environment_params_t & message_delivery_tracer_filter(so_5::msg_tracing::filter_shptr_t filter)
Set message tracer filter for the environment.
environment_params_t & exception_reaction(exception_reaction_t value) noexcept
Set exception reaction flag value.
subscription_storage_factory_t m_default_subscription_storage_factory
Default subscription storage factory.
const default_disp_params_t & default_disp_params() const
Get the parameters for the default dispatcher.
so_5::disp::abstract_work_thread_factory_shptr_t m_work_thread_factory
Global factory for work threads.
environment_params_t()
Constructor.
event_exception_logger_unique_ptr_t m_event_exception_logger
Exception logger.
event_queue_hook_unique_ptr_t so5_giveout_event_queue_hook()
Take out event_queue_hook object.
so_5::msg_tracing::filter_shptr_t m_message_delivery_tracer_filter
Message delivery tracer filter to be used with environment.
work_thread_activity_tracking_t work_thread_activity_tracking() const
Get activity tracking flag for the whole SObjectizer Environment.
const error_logger_shptr_t & so5_error_logger() const
Get error logger for the environment.
environment_params_t & operator=(environment_params_t &&other) noexcept
Move operator.
event_exception_logger_unique_ptr_t so5_giveout_event_exception_logger()
Get exception logger.
coop_listener_unique_ptr_t m_coop_listener
Cooperation listener.
environment_params_t & timer_thread(so_5::timer_thread_factory_t factory)
Set the timer_thread factory.
exception_reaction_t m_exception_reaction
Exception reaction flag for the whole SO Environment.
work_thread_activity_tracking_t m_work_thread_activity_tracking
Work thread activity tracking for the whole Environment.
const subscription_storage_factory_t & default_subscription_storage_factory() const noexcept
Get the current default subscription storage factory.
so_5::timer_thread_factory_t m_timer_thread_factory
Timer thread factory.
disp_binder_shptr_t so_make_default_disp_binder()
Get binding to the default dispatcher.
mbox_t create_mbox()
Create an anonymous MPMC mbox.
error_logger_t & error_logger() const
Get the error_logger object.
void imp_run_layers_and_go_further()
Run layers and call next run stage.
void add_extra_layer(const std::type_index &type, const layer_ref_t &layer)
Add an additional layer.
so_5::timer_id_t so_schedule_timer(const low_level_api::schedule_timer_params_t params)
Schedule timer event.
stats::repository_t & stats_repository()
Access to repository of data sources for run-time monitoring.
void add_extra_layer(std::unique_ptr< SO_Layer > layer_ptr)
Add an additional layer.
void change_message_delivery_tracer_filter(so_5::msg_tracing::filter_shptr_t filter)
Change the current msg_tracing's filter to a new one.
coop_handle_t register_agent_as_coop(std::unique_ptr< A > agent)
Register single agent as a cooperation.
void install_exception_logger(event_exception_logger_unique_ptr_t logger)
Set up an exception logger.
mbox_t introduce_named_mbox(mbox_namespace_name_t mbox_namespace, nonempty_name_t mbox_name, const std::function< mbox_t() > &mbox_factory)
Introduce named mbox with user-provided factory.
SO_Layer * query_layer_noexcept() const
void run()
Run the SObjectizer Run-Time.
environment_t & operator=(const environment_t &)=delete
void remove_extra_layer(const std::type_index &type)
Remove an additional layer.
mchain_t create_mchain(const mchain_params_t ¶ms)
Create message chain.
exception_reaction_t exception_reaction() const noexcept
An exception reaction for the whole SO Environment.
std::unique_ptr< internals_t > m_impl
SObjectizer Environment internals.
environment_t & self_ref()
Auxiliary methods for getting reference to itself.
std::unique_ptr< Agent > make_agent(Args &&... args)
Helper method for simplification of agents creation.
coop_handle_t register_agent_as_coop(std::unique_ptr< A > agent, disp_binder_shptr_t disp_binder)
Register single agent as a cooperation with specified dispatcher binder.
coop_unique_holder_t make_coop(coop_handle_t parent)
Create a new cooperation that will be a child for specified parent coop.
so_5::disp::abstract_work_thread_factory_shptr_t work_thread_factory() const noexcept
Access to the global work thread factory.
void call_exception_logger(const std::exception &event_exception, const coop_handle_t &coop) noexcept
Call event exception logger for logging an exception.
environment_t(environment_params_t &&so_environment_params)
stats::controller_t & stats_controller()
Access to controller of run-time monitoring.
layer_t * query_layer(const std::type_index &type) const
Access to an additional layer.
mbox_t make_custom_mbox(Lambda &&lambda)
Create a custom mbox.
void imp_run_infrastructure()
Launch environment infrastructure and wait for finish.
void imp_run_stats_controller_and_go_further()
Run controller for run-time monitoring and call next run stage.
coop_unique_holder_t make_coop()
Create a cooperation.
void stop() noexcept
Send a shutdown signal to the Run-Time.
work_thread_activity_tracking_t work_thread_activity_tracking() const
Get activity tracking flag for the whole SObjectizer Environment.
decltype(auto) introduce_coop(Args &&... args)
Helper method for simplification of cooperation creation and registration.
mbox_t do_make_custom_mbox(custom_mbox_details::creator_iface_t &creator)
Actual creation of a custom mbox.
void remove_stop_guard(stop_guard_shptr_t guard)
Remove stop_guard and complete the stop operation if necessary.
environment_t(const environment_t &)=delete
coop_handle_t register_coop(coop_unique_holder_t agent_coop)
Register a cooperation.
void deregister_coop(coop_handle_t coop, int reason) noexcept
Deregister the cooperation.
SO_Layer * query_layer() const
Get access to the layer with exception if layer is not found.
coop_unique_holder_t make_coop(disp_binder_shptr_t disp_binder)
Create a cooperation with specified dispatcher binder.
virtual void init()=0
Initialization hook.
mbox_t create_mbox(nonempty_name_t mbox_name)
Create named MPMC mbox.
void so_single_timer(const low_level_api::single_timer_params_t params)
Schedule a single shot timer event.
stop_guard_t::setup_result_t setup_stop_guard(stop_guard_shptr_t guard, stop_guard_t::what_if_stop_in_progress_t reaction_on_stop_in_progress=stop_guard_t::what_if_stop_in_progress_t::throw_exception)
Set up a new stop_guard.
bool autoshutdown_disabled() const
Get autoshutdown_disabled flag.
coop_unique_holder_t make_coop(coop_handle_t parent, disp_binder_shptr_t disp_binder)
Create a new cooperation that will be a child for specified parent coop.
An interface for logging error messages.
error_logger_t & operator=(error_logger_t &)=delete
virtual ~error_logger_t() noexcept=default
error_logger_t(const error_logger_t &)=delete
virtual void log(const char *file_name, unsigned int line, const std::string &message)=0
A method for logging message.
Interface of event_queue_hook object.
An interface of event queue for agent.
event_queue_t & operator=(const event_queue_t &)=delete
event_queue_t & operator=(event_queue_t &&)=delete
virtual void push(execution_demand_t demand)=0
Enqueue new event to the queue.
virtual ~event_queue_t() noexcept=default
virtual void push_evt_finish(execution_demand_t demand) noexcept=0
Enqueue a demand for evt_finish event.
virtual void push_evt_start(execution_demand_t demand)=0
Enqueue a demand for evt_start event.
event_queue_t(event_queue_t &&)=delete
event_queue_t(const event_queue_t &)=delete
The base class for all SObjectizer exceptions.
int error_code() const noexcept
Error code getter.
exception_t(const exception_t &)=default
exception_t(exception_t &&)=default
int m_error_code
Error code.
exception_t(const std::string &error_descr, int error_code)
exception_t & operator=(exception_t &&o) noexcept=default
exception_t & operator=(exception_t &o)=default
static void raise(const char *file_name, unsigned int line_number, std::string_view error_descr, int error_code)
A hint for a dispatcher for execution of event for the concrete execution_demand.
bool is_thread_safe() const
Is thread safe handler?
execution_hint_t(execution_demand_t &demand)
execution_hint_t(execution_demand_t &demand, direct_func_t direct_func, thread_safety_t thread_safety)
Initializing constructor.
thread_safety_t m_thread_safety
Thread safety for event handler.
void exec(current_thread_id_t working_thread_id) const
Call event handler directly.
direct_func_t m_direct_func
Function for call event handler directly.
static execution_hint_t create_empty_execution_hint(execution_demand_t &demand)
execution_demand_t & m_demand
A reference to demand for which that hint has been created.
A special class for accessing private members of agent_coop.
static void decrement_usage_count(coop_t &coop)
static void increment_usage_count(coop_t &coop) noexcept
Storage for message delivery filters.
A helper class for accessing the functionality of environment-class which is specific for SObjectizer...
event_queue_t * event_queue_on_bind(agent_t *agent, event_queue_t *original_queue) noexcept
Call the event_queue_hook when an agent is being bound to a particular event_queue.
void event_queue_on_unbind(agent_t *agent, event_queue_t *queue) noexcept
Call the event_queue_hook when an agent is being unbound from its event_queue.
bool is_msg_tracing_enabled() const
Is message delivery tracing enabled?
internal_env_iface_t(environment_t &env)
Initializing constructor.
mbox_t create_limitless_mpsc_mbox(agent_t &single_consumer)
Create multi-producer/single-consumer mbox that ignores message limits.
An utility class for working with layers.
Helper class for accessing protected members from mbox interface.
An interface for storage of message_sinks for one agent.
void add(internal_state_listener_unique_ptr_t listener)
Add a new listener.
static auto wrap_nondestroyable(agent_state_listener_t &listener)
static void actual_deleter(agent_state_listener_t *listener)
static void noop_deleter(agent_state_listener_t *)
container_t m_listeners
All listeners.
void changed(agent_t &agent, const state_t &state) noexcept
Handle state change.
static auto wrap_destroyable(agent_state_listener_unique_ptr_t listener)
agent_t::agent_status_t m_previous_status
state_switch_guard_t(agent_t &agent)
An interface of subscription storage.
Template class for smart reference wrapper on the atomic_refcounted_t.
bool operator==(const intrusive_ptr_t &o) const
intrusive_ptr_t(T *obj) noexcept
Constructor for a raw pointer.
T * m_obj
Object controlled by a smart reference.
void dismiss_object() noexcept
Decrement reference count to object and delete it if needed.
void reset() noexcept
Drop controlled object.
intrusive_ptr_t(const intrusive_ptr_t< Y > &o) noexcept
Constructor from another smart reference.
intrusive_ptr_t(std::unique_ptr< Y > o) noexcept
Constructor from unique_ptr instance.
intrusive_ptr_t(intrusive_ptr_t &&o) noexcept
Move constructor.
bool operator<(const intrusive_ptr_t &o) const
T * operator->() const noexcept
intrusive_ptr_t(const intrusive_ptr_t &o) noexcept
Copy constructor.
intrusive_ptr_t & operator=(const intrusive_ptr_t &o) noexcept
Copy operator.
intrusive_ptr_t & operator=(intrusive_ptr_t &&o) noexcept
Move operator.
intrusive_ptr_t< Y > make_reference() const noexcept
Make reference with casing to different type.
T & operator*() const noexcept
void take_object() noexcept
Increment reference count to object if it's not null.
static void ensure_right_T()
friend void swap(intrusive_ptr_t &a, intrusive_ptr_t &b) noexcept
Swap values.
intrusive_ptr_t() noexcept
Default constructor.
~intrusive_ptr_t() noexcept
Destructor.
operator bool() const noexcept
Is this a null reference?
An interface of the additional SObjectizer Environment layer.
error_logger_t & m_logger
std::ostringstream & stream()
std::ostringstream m_stream
conductor_t(const Env &env, const char *file, unsigned int line)
conductor_t(error_logger_t &logger, const char *file, unsigned int line)
An implementation of delivery filter represented by lambda-function like object.
lambda_as_filter_t(Lambda &&filter)
bool check(const abstract_message_sink_t &, message_t &msg) const noexcept override
Checker for a message instance.
A class for the name of mbox_namespace.
Parameters for message chain.
A class for holding an instance of a message.
static message_holder_t make(Args &&...args)
Create a new instance of message_holder with a new message inside.
friend void swap(message_holder_t &a, message_holder_t &b) noexcept
message_holder_t(std::piecewise_construct_t, Args &&...args)
static intrusive_ptr_t< envelope_type > make_msg_instance(Args &&...args)
Create a new instance of message.
any_unspecified_message()
~any_unspecified_message()
An interface of tracer for message delivery tracing.
A base class for agent messages.
message_t(const message_t &other)
virtual void so5_change_mutability(message_mutability_t mutability)
Change message mutabilty flag.
message_t & operator=(message_t &&other) noexcept
friend message_mutability_t message_mutability(const message_t &what) noexcept
Helper method for get message mutability flag.
virtual kind_t so5_message_kind() const noexcept
Detect the kind of the message.
virtual ~message_t() noexcept=default
friend message_kind_t message_kind(const message_t &what)
Helper method for quering kind of the message.
message_t & operator=(const message_t &other)
message_mutability_t m_mutability
Is message mutable or immutable?
friend message_mutability_t message_mutability(const intrusive_ptr_t< message_t > &what) noexcept
Helper method for safe get of message mutability flag.
virtual message_mutability_t so5_message_mutability() const noexcept
Get message mutability flag.
message_t(message_t &&other)
friend void change_message_mutability(message_t &what, message_mutability_t mutability)
Helper method for change message mutability flag.
friend message_kind_t message_kind(const so_5::intrusive_ptr_t< message_t > &what)
Helper method for quering kind of the message.
friend void change_message_mutability(intrusive_ptr_t< message_t > &what, message_mutability_t mutability)
Helper method for safe change message mutability flag.
A message wrapped to be used as type of argument for event handlers.
mhood_t(message_ref_t &mf)
Type for holding agent name.
unsigned int m_length
Name length.
name_for_agent_t & operator=(name_for_agent_t &&other) noexcept
name_for_agent_t(const name_for_agent_t &)
name_for_agent_t(name_for_agent_t &&other) noexcept
std::unique_ptr< char[] > m_value
Name storage.
bool has_value() const noexcept
Does this object have a value?
name_for_agent_t & operator=(const name_for_agent_t &)
std::string_view as_string_view() const
Get the value as a string_view.
name_for_agent_t()
Default constructor makes an null value.
operator bool() const noexcept
Does this object have a value?
name_for_agent_t(std::string_view value)
Initializing constructor.
A class for the name which cannot be empty.
Helper class for indication of long-lived reference via its type.
outliving_reference_t(T &r) noexcept
outliving_reference_t & operator=(outliving_reference_t const &o)=delete
outliving_reference_t(outliving_reference_t< U > const &o) noexcept
outliving_reference_t(T &&)=delete
outliving_reference_t(outliving_reference_t const &o) noexcept
Wrapper around a pointer to partially constructed agent.
partially_constructed_agent_ptr_t(agent_t *ptr)
agent_t * ptr() const noexcept
An implementation of backoff object using assembly instruction.
Scoped guard for shared locks.
read_lock_guard_t(const read_lock_guard_t &)=delete
read_lock_guard_t & operator=(const read_lock_guard_t &)=delete
read_lock_guard_t(Lock &l)
A simple multi-readers/single-writer spinlock (analog of std::shared_mutex).
void lock()
Lock object in exclusive mode.
static constexpr const std::uint_fast32_t unlocked
void unlock()
Unlock object locked in exclusive mode.
void unlock_shared()
Unlock object locked in shared mode.
std::atomic_uint_fast32_t m_counters
void lock_shared()
Lock object in shared mode.
static constexpr const std::uint_fast32_t write_lock
static constexpr const std::uint_fast32_t read_lock
rw_spinlock_t & operator=(const rw_spinlock_t &)=delete
rw_spinlock_t(const rw_spinlock_t &)=delete
A base class for agent signals.
signal_t(const signal_t &)=delete
signal_t(signal_t &&)=delete
signal_t & operator=(signal_t &&)=delete
kind_t so5_message_kind() const noexcept override
Detect the kind of the message.
signal_t & operator=(const signal_t &)=delete
~signal_t() noexcept override=default
abstract_message_sink_t & sink() noexcept override
Get a reference to the underlying message sink.
simple_sink_owner_t(Args &&...args)
Initializing constructor.
const abstract_message_sink_t & sink() const noexcept override
Get a const reference to the underlying message sink.
A simple spinlock (analog of std::mutex).
void unlock()
Unlock object.
spinlock_t(const spinlock_t &)=delete
std::atomic_bool m_flag
Atomic flag which is used as actual lock.
spinlock_t & operator=(spinlock_t &&)=delete
spinlock_t & operator=(const spinlock_t &)=delete
spinlock_t(spinlock_t &&)=delete
Helper class for simplify iteration on state's path.
state_t::path_t::const_iterator end() const noexcept
Get the past-the-end iterator for the path.
state_path_t & operator=(state_path_t &&)=delete
state_t::path_t m_path
Path for the state.
state_path_t(const state_path_t &)=delete
state_t::path_t::const_iterator m_past_the_end_it
state_path_t & operator=(const state_path_t &)=delete
state_path_t(const state_t &state) noexcept
Initializing constructor.
state_path_t(state_path_t &&)=delete
state_t::path_t::const_iterator begin() const noexcept
Get iterator for the very first item of the path.
Information of time_limit for a state.
void change(duration_t limit, const state_t &state_to_switch) noexcept
const state_t & state_to_switch() const noexcept
void on_state_activation(const agent_t::state_time_limit_handling_data_t &info) noexcept
bool is_limit_exceeded(const steady_clock::time_point current_time) const noexcept
std::optional< activation_data_t > m_activation_data
std::reference_wrapper< const state_t > m_state_to_switch
The target state to switch after the timeout.
void activate(const agent_t::state_time_limit_handling_data_t &info)
time_limit_t(duration_t limit, const state_t &state_to_switch) noexcept
Initializing constructor.
void on_state_deactivation() noexcept
bool is_target(const agent_t *agent) const noexcept
Is agent owner of this state?
state_t & time_limit(duration_t timeout, const state_t &state_to_switch)
Set up a time limit for the state.
std::enable_if< details::is_agent_method_pointer< details::method_arity::nullary, Method_Pointer >::value, state_t & >::type on_enter(Method_Pointer pfn)
Set on enter handler.
bool has_subscription(const mbox_t &from, Method_Pointer &&pfn) const
Check the presence of a subscription.
const state_t & just_switch_to(mbox_t from, const state_t &target_state) const
Define handler which only switches agent to the specified state.
state_t & drop_time_limit()
Drop time limit for the state if defined.
on_exit_handler_t m_on_exit
Handler for the exit from the state.
const state_t & suppress(mbox_t from) const
Suppress processing of event in this state.
state_t & transfer_to_state(mbox_t from, const state_t &target_state)
An instruction for switching agent to the specified state and transfering event proceessing to new st...
history_t m_state_history
Type of state history.
const state_t * parent_state() const noexcept
Get a parent state if exists.
void fill_path(path_t &path) const noexcept
A helper method for building a path from top-level state to this state.
state_t(substate_of parent, history_t state_history)
Constructor for the case when state is a substate of some parent state.
state_t & on_exit(on_exit_handler_t handler)
Set on exit handler.
state_t(initial_substate_of parent, std::string state_name, history_t state_history)
Constructor for the case when state is the initial substate of some parent state.
state_t(substate_of parent)
Constructor for the case when state is a substate of some parent state.
state_t & just_switch_to(mbox_t from, const state_t &target_state)
Define handler which only switches agent to the specified state.
std::size_t nested_level() const noexcept
Query nested level for the state.
bool is_active() const noexcept
Is this state or any of its substates activated?
state_t(state_t &&other)
Move constructor.
state_t(agent_t *target_agent, std::string state_name, state_t *parent_state, std::size_t nested_level, history_t state_history)
Fully initializing constructor.
const state_t & subscribe_message_handler(const mbox_t &from, Args &&... args) const
A helper for handle-methods implementation.
const state_t & event(Args &&... args) const
Helper for subscription of event handler in this state.
const state_t & suppress() const
Suppress processing of event in this state.
std::string m_state_name
State name.
state_t(agent_t *agent, std::string state_name, history_t state_history)
bool has_subscription(const mbox_t &from) const
Check the presence of a subscription.
state_t * m_parent_state
Parent state.
state_t(substate_of parent, std::string state_name, history_t state_history)
Constructor for the case when state is a substate of some parent state.
const state_t * actual_state_to_enter() const
Find actual state to be activated for agent.
void drop_subscription(const mbox_t &from, Method_Pointer &&pfn) const
Drop subscription.
state_t & on_enter(on_enter_handler_t handler)
Set on enter handler.
state_t(initial_substate_of parent)
Constructor for the case when state is the initial substate of some parent state.
state_t & transfer_to_state(const state_t &target_state)
An instruction for switching agent to the specified state and transfering event proceessing to new st...
const state_t * m_initial_substate
The initial substate.
bool operator==(const state_t &state) const noexcept
void clear_history() noexcept
Clear state history.
state_t(initial_substate_of parent, std::string state_name)
Constructor for the case when state is the initial substate of some parent state.
state_t & event(mbox_t from, Args &&... args)
const state_t & just_switch_to(const state_t &target_state) const
Define handler which only switches agent to the specified state.
size_t m_substate_count
Number of substates.
state_t(agent_t *agent, history_t state_history)
const on_exit_handler_t & on_exit() const
Query on enter handler.
void call_on_enter() const noexcept
Call for on enter handler if defined.
bool operator!=(const state_t &state) const noexcept
void call_on_exit() const noexcept
Call for on exit handler if defined.
agent_t *const m_target_agent
Owner of this state.
const state_t & transfer_to_state(mbox_t from, const state_t &target_state) const
An instruction for switching agent to the specified state and transfering event proceessing to new st...
std::string query_name() const
Get textual name of the state.
state_t & operator=(const state_t &)=delete
const state_t & transfer_to_state(const state_t &target_state) const
An instruction for switching agent to the specified state and transfering event proceessing to new st...
static constexpr const std::size_t max_deep
Max deep of nested states.
state_t(substate_of parent, std::string state_name)
Constructor for the case when state is a substate of some parent state.
const state_t * m_last_active_substate
Last active substate.
void handle_time_limit_on_enter() const
A special handler of time limit to be used on entering into state.
state_t(agent_t *agent, std::string state_name)
state_t & suppress(mbox_t from)
Suppress processing of event in this state.
state_t(const state_t &)=delete
const state_t & event(mbox_t from, Args &&... args) const
Helper for subscription of event handler in this state.
void activate() const
Switch agent to that state.
void drop_subscription(const mbox_t &from) const
Drop subscription.
history_t
Type of history for state.
@ none
State has no history.
@ deep
State has deep history.
@ shallow
State has shallow history.
on_enter_handler_t m_on_enter
Handler for the enter to the state.
const on_enter_handler_t & on_enter() const
Query on enter handler.
state_t & event(Args &&... args)
std::unique_ptr< time_limit_t > m_time_limit
A definition of time limit for the state.
state_t & suppress()
Suppress processing of event in this state.
std::size_t m_nested_level
Nesting level for state.
void update_history_in_parent_states() const
A helper method which is used during state change for update state with history.
void handle_time_limit_on_exit() const
A special handler of time limit to be used on exiting from state.
state_t & just_switch_to(const state_t &target_state)
Define handler which only switches agent to the specified state.
state_t(initial_substate_of parent, history_t state_history)
Constructor for the case when state is the initial substate of some parent state.
A public interface for control SObjectizer monitoring options.
An interface of data sources repository.
An interface of stop_guard entity.
setup_result_t
Type for result of setting up a new stop_guard.
what_if_stop_in_progress_t
@ throw_exception
An exception must be thrown.
A class for creating a subscription to messages from the mbox.
std::vector< const state_t * > state_vector_t
Type of vector of states.
mbox_t m_mbox_ref
Mbox for messages to subscribe.
subscription_bind_t & just_switch_to(const state_t &target_state)
Define handler which only switches agent to the specified state.
void create_subscription_for_states(const std::type_index &msg_type, const event_handler_method_t &method, thread_safety_t thread_safety, event_handler_kind_t handler_kind) const
Create subscription of event for all states.
subscription_bind_t(agent_t &agent, const mbox_t &mbox_ref)
subscription_bind_t & in(const state_t &state)
Set up a state in which events are allowed be processed.
subscription_bind_t & suppress()
Suppress processing of event in this state.
subscription_bind_t & transfer_to_state(const state_t &target_state)
An instruction for switching agent to the specified state and transfering event proceessing to new st...
state_vector_t m_states
States of agents the event to be subscribed in.
void ensure_handler_can_be_used_with_mbox(const so_5::details::msg_type_and_handler_pair_t &handler) const
Additional check for subscription to a mutable message from MPMC mbox.
agent_t * m_agent
Agent to which we are subscribing.
An indentificator for the timer.
An implementation of backoff object with usage of std::yield.
#define SO_5_LOG_ERROR(logger, var_name)
A special macro for helping error logging.
#define SO_5_LOG_ERROR_IMPL(logger, file, line, var_name)
An implementation for SO_5_LOG_ERROR macro.
#define SO_5_THROW_EXCEPTION_IMPL(file, line, error_code, desc)
#define SO_5_THROW_EXCEPTION(error_code, desc)
demand_handler_pfn_t select_demand_handler_for_message(const agent_t &agent, const message_ref_t &msg)
A helper function to select actual demand handler in dependency of message kind.
mbox_t make_direct_mbox_with_respect_to_custom_factory(partially_constructed_agent_ptr_t agent_ptr, const agent_tuning_options_t &tuning_options, mbox_t standard_mbox)
Helper for creation of the direct mbox for an agent.
unsigned int ensure_valid_agent_name_length(std::size_t length)
std::string create_anonymous_state_name(const agent_t *agent, const state_t *st)
const state_t deadletter_state(nullptr, "<DEADLETTER_STATE>")
A special object to be used as state for make subscriptions for deadletter handlers.
subscription_storage_factory_t detect_subscription_storage_factory_to_use(environment_t &env, const agent_tuning_options_t &tuning_options)
Helper for selection of subscription storage factory.
const state_t awaiting_deregistration_state(nullptr, "<AWAITING_DEREGISTRATION_AFTER_UNHANDLED_EXCEPTION>")
A special object for the state in which agent is awaiting for deregistration after unhandled exceptio...
Enumeration of cooperation deregistration reasons.
const int normal
Normal deregistration.
constexpr method_noexceptness_t noexcept_method
constexpr method_noexceptness_t not_noexcept_method
Various helpers for event subscription.
Agent * get_actual_agent_pointer(agent_t &agent)
Get actual agent pointer.
details::msg_type_and_handler_pair_t make_handler_from_lambda_of_free_function(Lambda &&lambda)
A function for creation event handler.
msg_type_and_handler_pair_t make_handler_with_arg(Handler_Type lambda)
Helper template for creation of event handler with actual argument.
Internal implementation details.
Helper templates for detection of lambda-type traits.
M * get_ptr(const intrusive_ptr_t< user_type_message_t< M > > &msg) noexcept
A helper function to get a const raw pointer from smart pointer.
M * get_ptr(const intrusive_ptr_t< M > &msg) noexcept
A helper function to get a const raw pointer from smart pointer.
Implementation details for implementation of rollback on exception helper.
Some reusable and low-level classes/functions which can be used in public header files.
auto make_message_instance(Args &&... args) -> std::unique_ptr< typename message_payload_type< Msg >::envelope_type >
A helper for allocate instance of a message.
mhood_type_t
A special selector for mhood_t implementations.
@ classical_signal
Message type is a classical signal derived from so_5::signal_t.
@ classical_message
Message type is a classical message derived from so_5::message_t.
@ user_type_message
Message type is not related to so_5::message_t.
auto do_with_rollback_on_exception(Main_Action main_action, Rollback_Action rollback_action) -> decltype(main_action())
Helper function for do some action with rollback in the case of an exception.
auto invoke_noexcept_code(L lambda) noexcept -> decltype(lambda())
method_arity
A special enumeration to specify arity of lambda-function or method.
@ nullary
Method or function has no arguments.
@ unary
Method or function has just one argument.
scope_exit_details::at_exit_t< L > at_scope_exit(L &&l)
Helper function for creation action to be performed at scope exit.
Dispatcher with single working thread.
SO_5_FUNC optional< message_ref_t > message_to_be_inspected(const message_ref_t &msg_or_envelope)
Helper function for extraction of a payload from enveloped message.
SO_5_FUNC optional< payload_info_t > extract_payload_for_message_transformation(const message_ref_t &envelope)
Helper function for extraction of a payload from enveloped message.
access_context_t
Information about context on that enveloped message is handled.
Internal namespace with details of agent_t implementation.
Various helpers for message delivery tracing mechanism.
void safe_trace_state_leaving(const agent_t &state_owner, const state_t &state)
Helper for tracing the fact of leaving a state.
void safe_trace_state_entering(const agent_t &state_owner, const state_t &state)
Helper for tracing the fact of entering into a state.
void trace_deadletter_handler_search_result(const execution_demand_t &demand, const char *context_marker, const event_handler_data_t *search_result)
Helper for tracing the result of search of deadletter handler.
void trace_event_handler_search_result(const execution_demand_t &demand, const char *context_marker, const event_handler_data_t *search_result)
Helper for tracing the result of event handler search.
Details of SObjectizer run-time implementations.
Implementation details of error_logging facility.
so_5::timer_id_t schedule_timer(const std::type_index &subscription_type, message_ref_t msg, const mbox_t &mbox, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period)
Schedule periodic timer event.
void ensure_not_null(const delivery_filter_unique_ptr_t &ptr)
Helper function that throws if a pointer to delivery_filter is null.
void single_timer(const std::type_index &subscription_type, message_ref_t msg, const mbox_t &mbox, std::chrono::steady_clock::duration pause)
Schedule single timer event.
void deliver_message(message_delivery_mode_t delivery_mode, abstract_message_box_t &target, std::type_index subscription_type, message_ref_t msg)
Deliver message.
coop_shptr_t to_shptr_noexcept(const coop_handle_t &) noexcept
A helper function for unsafe extraction of shared_ptr to coop from coop_handle instance.
void deliver_signal(message_delivery_mode_t delivery_mode, abstract_message_box_t &target)
Deliver signal.
void deliver_message(message_delivery_mode_t delivery_mode, abstract_message_box_t &target, std::type_index subscription_type, std::unique_ptr< Message > msg)
Deliver message.
coop_shptr_t to_shptr(const coop_handle_t &)
A helper function for safe extraction of shared_ptr to coop from coop_handle instance.
Internal implementation of message limits related stuff.
action_t make_action_for_message_transformer(Lambda &&transformator)
Helper function to make an action that performs message transformation.
SO_5_FUNC void redirect_reaction(const overlimit_context_t &ctx, const mbox_t &to)
Actual implementation of redirect message reaction.
SO_5_FUNC void abort_app_reaction(const overlimit_context_t &ctx)
Actual implementation of abort application reaction.
SO_5_FUNC void drop_message_reaction(const overlimit_context_t &ctx)
Actual implementation of drop message reaction.
action_t make_action_for_signal_transformer(Lambda &&transformator)
Helper function to make an action that performs signal transformation.
SO_5_FUNC void transform_reaction(const overlimit_context_t &ctx, const mbox_t &to, const std::type_index &msg_type, const message_ref_t &message)
Actual implementation of transform reaction.
All stuff related to message limits.
void accept_one_indicator(description_container_t &to, const log_then_abort_app_indicator_t< M, L > &indicator)
Helper function for accepting log_then_abort_app_indicator and storing the corresponding description ...
void accept_indicators(description_container_t &)
void accept_indicators(description_container_t &to, I &&indicator, Args &&... others)
Helper function for constructing limits description from a series of limit indicators.
void accept_one_indicator(description_container_t &to, const drop_indicator_t< M > &indicator)
Helper function for accepting drop_indicator and storing the corresponding description into the limit...
void accept_one_indicator(description_container_t &to, transform_indicator_t< M > indicator)
Helper function for accepting transform_indicator and storing the corresponding description into the ...
void accept_one_indicator(description_container_t &to, const abort_app_indicator_t< M > &indicator)
Helper function for accepting abort_app_indicator and storing the corresponding description into the ...
void accept_one_indicator(description_container_t &to, redirect_indicator_t< Msg, Lambda > indicator)
Helper function for accepting redirect_indicator and storing the corresponding description into the l...
Public part of message delivery tracing mechanism.
Helpers for working with priorities.
void for_each_priority(Lambda l)
Does enumeration of all priorities.
priority_t prev(priority_t p)
Get the previous priority value.
bool has_prev(priority_t p)
Is there lower priority?
const priority_t default_priority
Default priority value.
priority_t next(priority_t p)
Get the next priority value.
bool has_next(priority_t p)
Is there higher priority?
const unsigned int total_priorities_count
Total count of priorities.
All stuff related to run-time monitoring and statistics.
Private part of message limit implementation.
std::size_t to_size_t(priority_t priority)
Helper function for conversion from priority to size_t.
const int rc_nullptr_as_result_of_user_mbox_factory
nullptr returned by user-provided mbox factory.
SO_5_FUNC subscription_storage_factory_t flat_set_based_subscription_storage_factory(std::size_t initial_capacity)
Factory for subscription storage based on sorted std::vector.
const int rc_disp_create_failed
Unable to create a dispatcher.
const int rc_layer_not_binded_to_so_env
The layer is not bound to the SObjectizer Environment.
message_delivery_mode_t
Possible modes of message/signal delivery.
const int rc_coop_define_agent_failed
Cooperation couldn't be registered.
priority_t to_priority_t(std::size_t v)
Helper function for conversion from size_t to priority.
void ensure_message_with_actual_data(const Msg *m)
A special checker to guarantee that the message is an instance of the message_t (not signal_t) and ha...
const int rc_state_nesting_is_too_deep
Nesting of agent states is too deep.
const int rc_agent_incompatible_type_conversion
It is impossible to make a cast to that type.
const int rc_initial_substate_already_defined
Initial substate for a composite state is already defined.
const int rc_unable_to_start_extra_layer
Layer initialization is failed.
SO_5_FUNC subscription_storage_factory_t default_subscription_storage_factory()
Factory for default subscription storage object.
mbox_type_t
Type of the message box.
@ multi_producer_single_consumer
@ multi_producer_multi_consumer
const int rc_negative_value_for_pause
An attempt to use negative value for pause argument for delayed or periodic message/signal.
const int rc_prepared_select_is_active_now
An attempt to activate prepared-select when an operation on that prepared-select object is already ac...
void ensure_not_signal()
A special compile-time checker to guarantee that the message class is not a signal class.
const int rc_msg_chain_overflow
const int rc_coop_is_not_in_registered_state
An attempt to do something with coop that is not in registered state.
agent_context_t operator+(agent_context_t ctx, message_limit::abort_app_indicator_t< M > limit)
const int rc_mutable_msg_cannot_be_periodic
An attempt to send mutable message as a periodic message.
const int rc_cannot_set_stop_guard_when_stop_is_started
An attempt to set up a new stop_guard when the stop operation is already in progress.
constexpr unsigned int max_redirection_deep
Maximum deep of message redirections.
const int rc_no_preallocated_resources_for_agent
There are no resources that must have been in place for an agent in advance.
const int rc_transfer_to_state_loop
A loop in transfer_to_state detected.
exception_reaction_t
A reaction of SObjectizer to an exception from agent event.
@ abort_on_exception
Execution of application must be aborted immediatelly.
@ inherit_exception_reaction
Exception reaction should be inherited from SO Environment.
@ ignore_exception
Exception should be ignored and agent should continue its work.
@ deregister_coop_on_exception
@ shutdown_sobjectizer_on_exception
SO_5_FUNC error_logger_shptr_t create_stderr_logger()
A factory for creating error_logger implemenation which uses std::stderr as log stream.
void ensure_not_mutable_signal()
A special compile-time checker to guarantee that S is not a mutable signal.
const int rc_coop_already_destroyed
An attempt to get a pointer to already destroyed cooperation.
agent_context_t operator+(agent_context_t ctx, so_5::priority_t agent_priority)
demands_handling_on_dereg_t
How pending demands should be handled on deregistration.
@ skip
Pending demands have to be skipped.
@ normal
Pending demands have to be handled as usual.
const int rc_agent_name_too_long
Length of an agent name is too large.
current_thread_id_t null_current_thread_id()
Get NULL thread id.
const thread_safety_t not_thread_safe
Shorthand for thread unsafety indicator.
const int rc_msg_chain_is_full
Attempt to push a message to full message queue.
priority_t
Definition of supported priorities.
const thread_safety_t thread_safe
Shorthand for thread safety indicator.
const int rc_operation_enabled_only_on_agent_working_thread
An attempt to perform an operation which is enabled only on agent's working thread.
const int rc_autoshutdown_must_be_enabled
An attempt to launch environment with autoshutdown disabled in conditions where autoshutdown must be ...
const int rc_agent_is_not_the_state_owner
Agent doesn't own this state.
const int rc_scenario_must_be_completed
Testing scenario must be completed before an attempt to do the current operation.
const int rc_extensible_select_is_active_now
An attempt to modify or activate extensible-select when an operation on that extensible-select object...
const int rc_agent_unknown_state
Trying to switch to the unknown state.
message_mutability_t
A enum with variants of message mutability or immutability.
std::thread::id raw_id_from_current_thread_id(const current_thread_id_t &w)
Get the raw thread id from current_thread_id.
infinite_wait_indication
A type for special marker for infitite waiting on service request or on receive from mchain.
const int rc_trying_to_add_extra_layer_that_already_exists_in_extra_list
The layer is already bound to the SObjectizer Environment as an extra layer.
const int rc_several_limits_for_one_message_type
An attempt to define several limits for one message type.
const int rc_layer_does_not_exist
A layer with the specified type doesn't exist.
const int rc_invalid_time_limit_for_state
Invalid value of time limit for an agent's state.
const int rc_agent_to_disp_binding_failed
Binding of agent to dispatcher failed.
thread_safety_t
Thread safety indicator.
const int rc_priority_quote_illegal_value
Illegal value of quote for a priority.
const int rc_several_handlers_for_one_message_type
Attempt to define several handlers for one msg_type.
SO_5_FUNC subscription_storage_factory_t hash_table_based_subscription_storage_factory()
Factory for default subscription storage based on std::unordered_map.
const int rc_msg_chain_doesnt_support_subscriptions
Attempt to make subscription for message chain.
intrusive_ptr_t< Derived > make_agent_ref(Derived *agent)
Helper function template for the creation of smart pointer to an agent.
constexpr demands_handling_on_dereg_t skip_demands_on_dereg
Marker that tells that pending demands have to be skipped on deregistration.
const infinite_wait_indication infinite_wait
A special indicator for infinite waiting on service request or on receive from mchain.
decltype(auto) introduce_child_coop(agent_t &owner, Args &&... args)
A simple way for creating and registering child cooperation.
const int rc_stored_msg_inspection_result_not_found
There is no stored msg inspection result in the testing scenario.
message_kind_t
A enum with variants of message kinds.
@ user_type_message
Message is an user type message.
@ enveloped_msg
Message is an envelope with some other message inside.
agent_context_t operator+(agent_context_t ctx, message_limit::drop_indicator_t< M > limit)
const int rc_empty_agent_name
Name for an agent can't be empty.
const int rc_agent_deactivated
Agent can't change state because the agent is already deactivated.
no_wait_indication
A type for special marker for no waiting on service request or on receive from mchain.
SO_5_FUNC void swap(name_for_agent_t &a, name_for_agent_t &b) noexcept
const int rc_stored_state_name_not_found
There is no stored state name in the testing scenario.
mbox_id_t null_mbox_id()
Default value for null mbox_id.
const int rc_another_state_switch_in_progress
An attempt to switch agent state when another switch operation is in progress.
work_thread_activity_tracking_t
Values for dispatcher's work thread activity tracking.
@ off
Tracking is disabled.
@ unspecified
Tracking mode is specified elsewhere.
const no_wait_indication no_wait
A special indicator for no waiting on service request or on receive from mchain.
const int rc_unable_to_define_new_step
New step can't be defined if testing scenario is already started or finished.
const int rc_msg_tracing_disabled
Message delivery tracing is disabled and cannot be used.
message_ownership_t
Type of ownership of a message instance inside message_holder.
const int rc_unable_to_register_coop_during_shutdown
It is impossible to register cooperation during SObjectizer Environment shutdown.
intrusive_ptr_t(std::unique_ptr< T >) -> intrusive_ptr_t< T >
agent_context_t operator+(agent_context_t ctx, demands_handling_on_dereg_t handling_mode)
coop_unique_holder_t create_child_coop(coop_handle_t parent, Args &&... args)
A simple way for creating child cooperation when there is a reference to the parent cooperation objec...
msink_t SO_5_FUNC wrap_to_msink(const mbox_t &mbox, priority_t sink_priority=prio::p0)
Helper for wrapping an existing mbox into message_sink.
delivery_possibility_t
Result of checking delivery posibility.
@ disabled_by_delivery_filter
const int rc_no_initial_substate
An attempt to change agent state to a new composite state which have no initial state defined.
const int rc_unable_to_join_thread_by_itself
An attempt to call join() from the joinable thread itself.
SO_5_FUNC subscription_storage_factory_t adaptive_subscription_storage_factory(std::size_t threshold, const subscription_storage_factory_t &small_storage_factory, const subscription_storage_factory_t &large_storage_factory)
Factory for adaptive subscription storage.
const int rc_agent_has_no_cooperation
Agent is not bound to a cooperation.
const int rc_null_message_data
Null message data.
const int rc_illegal_subscriber_for_mpsc_mbox
An attempt to create illegal subscription to mpsc_mbox.
const int rc_msg_chain_is_empty
Attempt to get message from empty message queue.
outliving_reference_t< const T > outliving_const(T const &r)
Make outliving_reference wrapper for const reference.
decltype(auto) introduce_child_coop(coop_handle_t parent, Args &&... args)
A simple way for creating and registering child cooperation when there is a reference to parent coop.
const int rc_unknown_exception_type
An exception of unknown type is caught.
void ensure_signal()
A special compile-time checker to guarantee that the Msg is derived from the signal_t.
void ensure_classical_message()
A special compile-time checker to guarantee that Msg is derived from message_t.
SO_5_FUNC subscription_storage_factory_t vector_based_subscription_storage_factory(std::size_t initial_capacity)
Factory for subscription storage based on unsorted std::vector.
transformed_message_t< Msg > make_transformed(mbox_t mbox, Args &&... args)
Helper function for creation of an instance of transformed_message_t.
disp_binder_shptr_t make_default_disp_binder(environment_t &env)
Create an instance of the default dispatcher binder.
const int rc_msg_chain_doesnt_support_delivery_filters
Attempt to set delivery_filter for message chain.
const int rc_environment_error
so_environment launch is failed.
outliving_reference_t< const T > outliving_const(outliving_reference_t< T > r)
Make outliving_reference wrapper for const reference.
SO_5_FUNC subscription_storage_factory_t map_based_subscription_storage_factory()
Factory for subscription storage based on std::map.
const int rc_empty_name
The empty name doesn't allowed.
const int rc_unexpected_error
Unclassified error.
SO_5_FUNC subscription_storage_factory_t adaptive_subscription_storage_factory(std::size_t threshold)
Factory for adaptive subscription storage.
agent_context_t operator+(environment_t &env, Option arg)
A plus operator for creating agent_context object from a reference to Environment and single agent tu...
agent_context_t operator+(agent_context_t ctx, message_limit::redirect_indicator_t< M, L > limit)
coop_unique_holder_t create_child_coop(agent_t &owner, Args &&... args)
A simple way for creating child cooperation.
agent_context_t operator+(agent_context_t ctx, message_limit::log_then_abort_app_indicator_t< M, L > limit)
agent_context_t operator+(agent_context_t ctx, subscription_storage_factory_t factory)
const int rc_attempt_to_cast_to_envelope_on_nullptr
An attempt to cast message to message envelope when a pointer to message is NULL.
const int rc_evt_handler_already_provided
A handler for that event/mbox/state is already registered.
agent_context_t operator+(agent_context_t ctx, name_for_agent_t agent_name)
const int rc_mutable_msg_cannot_be_delivered_via_mpmc_mbox
An attempt to deliver mutable message via MPMC mbox.
const int rc_trying_to_add_extra_layer_that_already_exists_in_default_list
The layer is already bound to the SObjectizer Environment as a default layer.
event_handler_kind_t
Kind of an event handler.
const int rc_disp_binder_already_set_for_agent
The dispatcher binder is already set for the agent.
current_thread_id_t query_current_thread_id()
Get the ID of the current thread.
const int rc_nullptr_as_delivery_filter_pointer
nullptr can't be passed as delivery_filter.
const int rc_not_implemented
Feature or method has no implementation yet.
const int rc_message_has_no_limit_defined
An attempt to create subscription to message without predefined limit for that message type.
const int rc_negative_value_for_period
An attempt to use negative value for period argument for periodic message/signal.
outliving_reference_t< T > outliving_mutable(T &r)
Make outliving_reference wrapper for mutable reference.
const int rc_mpsc_mbox_expected
An instance of MPSC mbox is expected as custom direct mbox.
transformed_message_t< Msg > make_transformed(mbox_t mbox, message_holder_t< Msg, Ownership > msg_holder)
Helper function for creation of an instance of transformed_message_t.
const int rc_subscription_to_mutable_msg_from_mpmc_mbox
An attempt to make subscription on mutable message from MPMC mbox.
const int rc_trying_to_add_nullptr_extra_layer
Unable to bind a layer by the null pointer to it.
agent_context_t operator+(agent_context_t ctx, message_limit::transform_indicator_t< M > limit)
const int rc_no_disp_binder_for_agent
The dispatcher binder is not set for the agent yet.
Type for case when agent has user-provided name.
std::string_view m_name
Value.
Type for case when agent has no user-provided name.
SO_5_FUNC std::array< char, c_string_size > make_c_string() const noexcept
Make a c-string with text representation of a value.
static constexpr std::string_view c_string_prefix
Prefix to be used for string representation.
static constexpr std::size_t c_string_size
const agent_t * m_pointer_value
Value.
static constexpr std::string_view c_string_suffix
Suffix to be used for string representation.
void operator()(const pointer_only_t &v) const
to_ostream_visitor_t(std::ostream &to)
void operator()(const actual_name_t &v) const
std::string operator()(const pointer_only_t &v) const
std::string operator()(const actual_name_t &v) const
static constexpr const method_arity arity
static constexpr const bool is_noexcept
static constexpr const bool value
static constexpr const method_arity arity
static constexpr const bool value
static constexpr const bool is_noexcept
A simple metafunction that always "returns" false.
static constexpr const bool value
static void ensure_appropriate_type()
static immutable_msg< Msg > make_arg(message_ref_t &)
static void ensure_appropriate_type()
static mhood_t< immutable_msg< Msg > > make_arg(message_ref_t &mf)
static mhood_t< mutable_msg< Msg > > make_arg(message_ref_t &mf)
static void ensure_appropriate_type()
static void ensure_appropriate_type()
static mhood_t< Msg > make_arg(message_ref_t &mf)
static void ensure_appropriate_type()
static mutable_msg< Msg > make_arg(message_ref_t &)
A helper template for create an argument for event handler in the case when argument is passed as val...
static void ensure_appropriate_type()
static const Msg & make_arg(message_ref_t &mf)
Check whether T is a non-static member function pointer.
static constexpr const bool value
A detector of lambda argument type if the checked type is lambda.
A checker for lambda likeness.
A detector that type is a lambda or functional object.
static constexpr const bool value
Detector of plain type without const/volatile modifiers.
static R call_with_arg(R(*l)(M), M m)
Helper for calling a lambda.
static R call_with_arg(R(*l)(M), M m)
Helper for calling a lambda.
static R call_without_arg(L l)
Helper for calling a lambda.
static R call_with_arg(L l, M m)
Helper for calling a lambda.
Detector of lambda result and argument type.
static std::unique_ptr< Msg > make()
static std::unique_ptr< E > make(Args &&... args)
A meta-function for selection of type of accessors mixin.
A meta-function for selection a base of message_holder implementation in compile-time.
static const constexpr message_mutability_t mutability
static const constexpr message_mutability_t mutability
Detector of message type traits in dependency of message immutability or mutability.
static const constexpr message_mutability_t mutability
A special detector of message immutability/mutability.
static constexpr const message_mutability_t mutability
A special selector of message hood type.
static constexpr const mhood_type_t mhood_type
Description of an event handler.
bool operator<(const msg_type_and_handler_pair_t &o) const
Comparison (strictly less than).
msg_type_and_handler_pair_t(std::type_index msg_type)
Constructor for the case when only msg_type is known.
friend void swap(msg_type_and_handler_pair_t &a, msg_type_and_handler_pair_t &b) noexcept
Swap operation.
msg_type_and_handler_pair_t(const msg_type_and_handler_pair_t &o)
Copy constructor.
msg_type_and_handler_pair_t & operator=(msg_type_and_handler_pair_t &&o) noexcept
Move operator.
std::type_index m_msg_type
Type of a message or signal.
msg_type_and_handler_pair_t()
Default constructor.
msg_type_and_handler_pair_t(msg_type_and_handler_pair_t &&o) noexcept
Move constructor.
event_handler_method_t m_handler
A handler for processing this message or signal.
msg_type_and_handler_pair_t(std::type_index msg_type, event_handler_method_t handler, message_mutability_t mutability)
Initializing constructor.
bool operator==(const msg_type_and_handler_pair_t &o) const
Comparison (strictly equal).
msg_type_and_handler_pair_t & operator=(const msg_type_and_handler_pair_t &o)
Copy operator.
message_mutability_t m_mutability
What message is expected by handler: mutable or immutable.
static void exec(Main_Action main_action, rollbacker_t< Rollback_Action > &rollback)
static Result exec(Main_Action main_action, rollbacker_t< Rollback_Action > &rollback)
Internal details of SObjectizer Environment object.
A description of event execution demand.
mbox_id_t m_mbox_id
ID of mbox.
void call_handler(current_thread_id_t thread_id)
Helper method to simplify demand execution.
demand_handler_pfn_t m_demand_handler
Demand handler.
agent_t * m_receiver
Receiver of demand.
message_ref_t m_message_ref
Event incident.
execution_demand_t() noexcept
Default constructor.
const message_limit::control_block_t * m_limit
Optional message limit for that message.
execution_demand_t(agent_t *receiver, const message_limit::control_block_t *limit, mbox_id_t mbox_id, std::type_index msg_type, message_ref_t message_ref, demand_handler_pfn_t demand_handler) noexcept
std::type_index m_msg_type
Type of the message.
A helper class for temporary setting and then dropping the ID of the current working thread.
so_5::current_thread_id_t & m_id
working_thread_id_sentinel_t(so_5::current_thread_id_t &id_var, so_5::current_thread_id_t value_to_set)
~working_thread_id_sentinel_t()
Information about event_handler and its properties.
thread_safety_t m_thread_safety
Is event handler thread safe or not.
event_handler_kind_t m_kind
Kind of this event handler.
Helper class to be used as a comparator for msinks.
bool operator()(const msink_t &a, const msink_t &b) const noexcept
static std::pair< const abstract_sink_owner_t *, so_5::priority_t > safe_get_pair(const msink_t &from) noexcept
Helper for marking initial substate of composite state.
initial_substate_of(state_t &parent_state)
A helper class for checking that message is a classical message derived from message_t class.
A helper class for checking that message is a mutable message.
A helper class for checking that message is a signal.
A helper for detection presence of message of user type.
const mbox_t & m_mbox
Mbox to which message will be delivered.
const message_ref_t & m_msg
Message to be sent after timeout.
std::chrono::steady_clock::duration m_period
Period of the delivery repetition for periodic messages.
std::chrono::steady_clock::duration m_pause
Timeout before the first delivery.
const std::type_index & m_msg_type
Message type.
const mbox_t & m_mbox
Mbox to which message will be delivered.
const std::type_index & m_msg_type
Message type.
std::chrono::steady_clock::duration m_pause
Timeout before the delivery.
const message_ref_t & m_msg
Message to be sent after timeout.
Message limit with reaction 'abort the application'.
const unsigned int m_limit
Max count of waiting messages.
abort_app_indicator_t(unsigned int limit)
Initializing constructor.
A control block for one message limit.
action_t m_action
Limit overflow reaction.
std::atomic_uint m_count
The current count of the messages of that type.
control_block_t(unsigned int limit, action_t action)
Initializing constructor.
unsigned int m_limit
Limit value.
static const control_block_t * none()
A special indicator about absence of control_block.
control_block_t & operator=(const control_block_t &o)
Copy operator.
static void decrement(const control_block_t *limit)
control_block_t(const control_block_t &o)
Copy constructor.
A description of one message limit.
std::type_index m_msg_type
Type of message.
description_t(std::type_index msg_type, unsigned int limit, action_t action)
Initializing constructor.
unsigned int m_limit
Max count of waiting messages.
action_t m_action
Reaction to overload.
Message limit with reaction 'drop new message'.
drop_indicator_t(unsigned int limit)
Initializing constructor.
const unsigned int m_limit
Max count of waiting messages.
static void call(const overlimit_context_t &ctx, L action)
Helper class for calling pre-abort action.
static void call(const overlimit_context_t &ctx, L action)
Helper class for calling pre-abort action.
Message limit with reaction 'abort the application' and the possibility to call additional lambda bef...
const L m_lambda
Lambda for some last actions.
const unsigned int m_limit
Max count of waiting messages.
log_then_abort_app_indicator_t(unsigned int limit, L lambda)
Initializing constructor.
A mixin with message limit definition methods.
static drop_indicator_t< Msg > limit_then_drop(unsigned int limit)
A helper function for creating drop_indicator.
static redirect_indicator_t< Msg, Lambda > limit_then_redirect(unsigned int limit, Lambda dest_getter)
A helper function for creating redirect_indicator.
static transform_indicator_t< Source > limit_then_transform(unsigned int limit, Lambda &&transformator)
A helper function for creating transform_indicator.
static log_then_abort_app_indicator_t< M, L > limit_then_abort(unsigned int limit, L lambda)
A helper function for creating log_then_abort_app_indicator.
static abort_app_indicator_t< Msg > limit_then_abort(unsigned int limit)
A helper function for creating abort_app_indicator.
static auto limit_then_redirect(unsigned int limit, mbox_t destination)
A helper function for creating redirect_indicator.
static transformed_message_t< Msg > make_transformed(mbox_t mbox, Args &&... args)
Helper method for creating message transformation result.
static auto limit_then_transform(unsigned int limit, Lambda &&transformator)
A helper function for creating transform_indicator.
Description of context for overlimit action.
const message_delivery_mode_t m_delivery_mode
Delivery mode for message delivery attempt.
overlimit_context_t(mbox_id_t mbox_id, message_delivery_mode_t delivery_mode, const agent_t &receiver, const control_block_t &limit, unsigned int reaction_deep, const std::type_index &msg_type, const message_ref_t &message, const impl::action_msg_tracer_t *msg_tracer)
Initializing constructor.
const mbox_id_t m_mbox_id
ID of mbox which is used for message delivery.
const control_block_t & m_limit
Control block for message limit.
const unsigned int m_reaction_deep
The current deep of overlimit reaction recursion.
const agent_t & m_receiver
Receiver of the message (or enveloped message).
const std::type_index & m_msg_type
Type of message to be delivered.
const message_ref_t & m_message
A message (or enveloped message) to be delivered.
const impl::action_msg_tracer_t * m_msg_tracer
An optional pointer to tracer object for message delivery tracing.
Indication that a message must be redirected on overlimit.
Lambda m_destination_getter
A lambda/functional object which returns mbox for redirection.
const unsigned int m_limit
Max count of waiting messages.
redirect_indicator_t(unsigned int limit, Lambda destination_getter)
Initializing constructor.
static constexpr message_mutability_t mutability()
Helper for getting message mutability flag.
static payload_type & payload_reference(message_t &msg)
Helper for getting a const reference to payload part.
static constexpr const bool is_signal
Is it a signal type or message type.
static payload_type * extract_payload_ptr(message_ref_t &msg)
Helper for extraction of pointer to payload part.
static envelope_type * extract_envelope_ptr(message_ref_t &msg)
Helper for extraction of pointer to envelope part.
static std::type_index subscription_type_index()
Type ID for subscription.
Implementation details for message_payload_type.
static constexpr message_mutability_t mutability()
Helper for getting message mutability flag.
static payload_type & payload_reference(message_t &msg)
Helper for getting a const reference to payload part.
static envelope_type * extract_envelope_ptr(message_ref_t &msg)
Helper for extraction of pointer to envelope part.
static std::type_index subscription_type_index()
Type ID for subscription.
static constexpr const bool is_signal
Is it a signal type or message type.
static payload_type * extract_payload_ptr(message_ref_t &msg)
Helper for extraction of pointer to payload part.
A helper class for detection of payload type of message.
Helper type with method to be mixed into agent class.
static name_for_agent_t name_for_agent(std::string_view name)
A helper factory for making name_for_agent_t instance.
activation_data_t(timer_id_t timer, steady_clock::time_point expiration_point)
steady_clock::time_point m_expiration_point
Timeout of timeout expiration.
timer_id_t m_timer
ID of delayed timeout signal.
Helper for marking a substate of composite state.
substate_of(state_t &parent_state)
Template class for representing object of user type as a message.
user_type_message_t(T &&o)
Initialization from temporary T object.
kind_t so5_message_kind() const noexcept override
Detect the kind of the message.
user_type_message_t(T &o)
Initialization from non-const T object.
T m_payload
Instance of user message.
user_type_message_t(const T &o)
Initialization from const T object.
user_type_message_t(Args &&... args)
Initializing constructor.
#define SO_5_VERSION_PATCH
#define SO_5_VERSION_MAJOR
#define SO_5_VERSION_MAKE(major, minor, patch)
#define SO_5_VERSION_MINOR