-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
98 changed files
with
9,277 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// // | ||
// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // | ||
// Copyright (C) 2016-2017 Seadex GmbH // | ||
// // | ||
// Licensing information is available in the folder "license" which is part of this distribution. // | ||
// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // | ||
// // | ||
////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
#ifndef ALGORITHM_PARAMETERS_767C0EB2_9811_4764_8218_7F94032C29FD | ||
#define ALGORITHM_PARAMETERS_767C0EB2_9811_4764_8218_7F94032C29FD | ||
|
||
|
||
namespace sxy | ||
{ | ||
|
||
|
||
extern const int TRANSITION_PRIORITIES_VECTOR_SIZE; | ||
extern const int EXECUTION_STEPS_VECTOR_SIZE; | ||
extern const int TRANSITION_STEPS_VECTOR_SIZE; | ||
extern const int COMPOUND_TRANSITIONS_VECTOR_SIZE; | ||
extern const int STATES_TO_EXIT_VECTOR_SIZE; | ||
extern const int EXCEPTION_EVENTS_VECTOR_SIZE; | ||
extern const int CHOICES_VECTOR_SIZE; | ||
extern const int ENABLED_COMPOUND_TRANSITION_VECTOR_SIZE; | ||
extern const int DEFERRED_EVENTS_VECTOR_SIZE; | ||
extern const int DEFAULT_TRANSITIONS_OF_HISTORY_VECTORS_SIZE; | ||
extern const int ENTRY_POINTS_VECTOR_SIZE; | ||
extern const int EXIT_POINTS_VECTOR_SIZE; | ||
extern const int PSEUDOSTETS_IN_REGION_VECTOR_SIZE; | ||
extern const int ANCESTORS_VECTOR_SIZE; | ||
extern const int ASCENDING_PATH_ANCESTORS_VECTOR_SIZE; | ||
extern const int REGIONS_OF_FINAL_STATE; | ||
extern const int REGIONS_OF_SIMPLE_STATE; | ||
extern const int ANCESTORS_REGION_VECTOR_SIZE; | ||
extern const int ACTIVE_STATE_CONFIGRATION_VECTOR_SIZE; | ||
|
||
|
||
} | ||
|
||
|
||
#endif |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// // | ||
// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // | ||
// Copyright (C) 2016-2017 Seadex GmbH // | ||
// // | ||
// Licensing information is available in the folder "license" which is part of this distribution. // | ||
// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // | ||
// // | ||
////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
#ifndef ASYNC_BEHAVIOR_A799E0CD_DD3E_45EA_BF47_586C94FC32CB | ||
#define ASYNC_BEHAVIOR_A799E0CD_DD3E_45EA_BF47_586C94FC32CB | ||
|
||
|
||
#include "essentials/non_copyable.hpp" | ||
#include "essentials/compatibility/thread.hpp" | ||
|
||
#include "async_behavior_fwd.hpp" | ||
|
||
|
||
namespace sxy | ||
{ | ||
|
||
|
||
class event; | ||
class simple_state_base; | ||
class async_event_handler; | ||
class event_collector; | ||
|
||
|
||
class async_behavior | ||
{ | ||
|
||
|
||
public: | ||
async_behavior(); | ||
virtual ~async_behavior() SX_NOEXCEPT; | ||
SX_NO_COPY(async_behavior) | ||
void run( const event& _event, event_collector& _event_collector, const simple_state_base& _simple_state, async_event_handler& _async_event_handler ); | ||
void halt_and_join(); | ||
|
||
protected: | ||
bool should_stop() const; | ||
|
||
|
||
private: | ||
void work( const event& _event, event_collector& _event_collector, const simple_state_base& _simple_state, | ||
async_event_handler& _async_event_handler ); | ||
virtual void run_impl( const event& _event, event_collector& _event_collector, | ||
async_event_handler& _async_event_handler ) = 0; | ||
virtual void notify_should_stop(); | ||
void join(); | ||
|
||
sxe::SX_UNIQUE_PTR<sxe::thread> worker_; | ||
mutable sxe::mutex mutex_; | ||
bool run_; | ||
|
||
|
||
}; | ||
|
||
|
||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// // | ||
// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // | ||
// Copyright (C) 2016-2017 Seadex GmbH // | ||
// // | ||
// Licensing information is available in the folder "license" which is part of this distribution. // | ||
// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // | ||
// // | ||
////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
#ifndef ASYNC_BEHAVIOR_FWD_3D83004F_A880_4A4D_B60C_CE80DA56F1D7 | ||
#define ASYNC_BEHAVIOR_FWD_3D83004F_A880_4A4D_B60C_CE80DA56F1D7 | ||
|
||
|
||
#include "essentials/compatibility/compatibility.hpp" | ||
|
||
|
||
namespace sxy | ||
{ | ||
|
||
|
||
class async_behavior; | ||
class event; | ||
typedef sxe::SX_UNIQUE_PTR< async_behavior > async_behavior_uptr; | ||
|
||
|
||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// // | ||
// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // | ||
// Copyright (C) 2016-2017 Seadex GmbH // | ||
// // | ||
// Licensing information is available in the folder "license" which is part of this distribution. // | ||
// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // | ||
// // | ||
////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
#ifndef ASYNC_EVENT_HANDLER_314E2E70_50A4_442B_BE7C_E7F3FC77D71E | ||
#define ASYNC_EVENT_HANDLER_314E2E70_50A4_442B_BE7C_E7F3FC77D71E | ||
|
||
#include "event_fwd.hpp" | ||
|
||
|
||
namespace sxy | ||
{ | ||
|
||
|
||
class async_event_handler | ||
{ | ||
|
||
|
||
public: | ||
async_event_handler() | ||
{ | ||
// Nothing to do... | ||
} | ||
|
||
|
||
virtual ~async_event_handler() SX_NOEXCEPT | ||
{ | ||
// Nothing to do... | ||
} | ||
|
||
|
||
SX_NO_COPY(async_event_handler) | ||
virtual void on_event( const event_sptr& _event ) = 0; | ||
|
||
|
||
}; | ||
|
||
|
||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// // | ||
// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // | ||
// Copyright (C) 2016-2017 Seadex GmbH // | ||
// // | ||
// Licensing information is available in the folder "license" which is part of this distribution. // | ||
// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // | ||
// // | ||
////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
#ifndef ASYNC_SIMPLE_STATE_905AB129_358B_4868_8215_40BD3D95F9FD | ||
#define ASYNC_SIMPLE_STATE_905AB129_358B_4868_8215_40BD3D95F9FD | ||
|
||
|
||
#include "simple_state_base.hpp" | ||
#include "async_behavior_fwd.hpp" | ||
|
||
|
||
namespace sxy | ||
{ | ||
|
||
|
||
class async_simple_state_impl SX_FINAL: | ||
public simple_state_base | ||
{ | ||
public: | ||
explicit async_simple_state_impl( const std::string& _name, async_behavior_uptr _do_action, | ||
behavior_uptr _entry_action = behavior_uptr(), behavior_uptr _exit_action = behavior_uptr(), | ||
const event_ids& _deferred_events = event_ids(), event_sptr _error_event = event_sptr()); | ||
virtual ~async_simple_state_impl() SX_NOEXCEPT SX_OVERRIDE; | ||
SX_NO_COPY(async_simple_state_impl) | ||
void execute_do_behavior( const event& _event, async_event_handler* const _async_event_handler, | ||
event_collector& _event_collector ) const SX_OVERRIDE; | ||
void execute_exit_behavior( const event& _event, event_collector& _event_collector ) const SX_OVERRIDE; | ||
void stop_do_behavior() const; | ||
|
||
|
||
private: | ||
async_behavior_uptr do_; | ||
}; | ||
|
||
|
||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// // | ||
// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // | ||
// Copyright (C) 2016-2017 Seadex GmbH // | ||
// // | ||
// Licensing information is available in the folder "license" which is part of this distribution. // | ||
// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // | ||
// // | ||
////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
#ifndef ASYNC_STATE_MACHINE_5D531F9B_A0F2_47FF_BCFC_3264896355C5 | ||
#define ASYNC_STATE_MACHINE_5D531F9B_A0F2_47FF_BCFC_3264896355C5 | ||
|
||
|
||
#include <list> | ||
|
||
#include "essentials/compatibility/thread.hpp" | ||
#include "essentials/compatibility/chrono.hpp" | ||
|
||
#include "state_machine_base.hpp" | ||
#include "async_event_handler.hpp" | ||
#include "state_machine_status.hpp" | ||
|
||
|
||
namespace sxy | ||
{ | ||
|
||
|
||
//!\class async_state_machine | ||
//!\brief Class for the "multi-threaded version" of the state machine. Provides methods to start and halt the state | ||
//! machine and to fire events. | ||
class async_state_machine SX_FINAL: | ||
public state_machine_base, private async_event_handler | ||
{ | ||
public: | ||
//!\brief Constructor. | ||
//!\param _name Name of the state machine. | ||
//!\param _event_processing_callback Event processing callback interface pointer. It can be a nullptr if no callback | ||
//!interface should be used. | ||
explicit async_state_machine( const std::string& _name, | ||
event_processing_callback* const _event_processing_callback = SX_NULLPTR ); | ||
virtual ~async_state_machine() SX_NOEXCEPT SX_OVERRIDE; | ||
SX_NO_COPY(async_state_machine) | ||
|
||
//!\brief Enqueue the given event for firing. | ||
//!\param _event Event to be fired. | ||
//!\return true if event was successfully enqueued for firing, else false. It returns false if the enqueue for firing | ||
//!of the event is not possible because the state machine was stopped in the meantime (or was never started). | ||
//!Firing the event enqueues the event for being processed. | ||
virtual bool fire_event( const event_sptr& _event ) SX_OVERRIDE; | ||
|
||
//!\brief Starts the state machine. When starting the state machine, the initial transitions are searched and | ||
//!executed. Without running the state machine, it is not possible to fire events. | ||
//!\return If the state machine reaches a terminate pseudostate after starting (on calling run), returns false. Else | ||
//!if the state machine is started and running, returns true. | ||
//!\sa halt_and_join, halt, join | ||
virtual bool run() SX_OVERRIDE; | ||
|
||
//!\brief Stops and joins the state machine. When stopping the state machine, all the events remaining in the queue | ||
//!of events will be processed and the event processing thread will be then stopped and joined. The state machine | ||
//!will also check for active asynchronous simple states and will stop the do behavior for all of them. | ||
//!\return void | ||
//!\sa halt, join, run | ||
void halt_and_join(); | ||
|
||
//!\brief Stops the state machine. When stopping the state machine, all the events remaining in the queue | ||
//!of events will be processed and the event processing thread will be then stopped and joined. The state machine | ||
//!will also check for active asynchronous simple states and will stop the do behavior for all of them. | ||
//!\return void | ||
//!\sa halt_and_join, join, run | ||
virtual void halt() SX_OVERRIDE; | ||
|
||
//!\brief Joins the thread of the state machine. | ||
//!\return void | ||
//!\sa halt_and_join, halt, run | ||
void join(); | ||
|
||
|
||
//!\brief Waiting given amount of time for the state machine to terminate (or to stop). | ||
//!\param _timeoutInMs Time in milliseconds to wait for the state machine to terminate. | ||
//!\return bool true if the state machine is terminated or stopped, false otherwise. | ||
//!\sa halt_and_join, halt, run, wait | ||
bool wait( const sxe::milliseconds _timeoutInMs ) const; | ||
|
||
//!\brief Wait for the machine to terminate (or to stop). | ||
//!\return void | ||
//!\sa halt_and_join, halt, run, wait | ||
void wait() const; | ||
|
||
//!\brief Check if the state machine is terminated or stopped. | ||
//!\return bool true if the state machine is terminated or stopped, false otherwise. | ||
//!\sa halt_and_join, halt, run, wait | ||
bool terminated() const; | ||
|
||
|
||
//!\brief Enqueue the given event for firing. | ||
//!\param _event Event to be fired. | ||
//!\return true if event was successfully enqueued for firing, else false. It returns false if the enqueue for firing | ||
//!of the event is not possible because the state machine was stopped in the meantime (or was never started). | ||
//!Firing the event enqueues the event for being processed. | ||
virtual bool push( const event_sptr& _event ) SX_OVERRIDE; | ||
|
||
|
||
protected: | ||
void start_state_machine(); | ||
|
||
|
||
private: | ||
bool insert( const event_sptr& _event ); | ||
void insert_impl( const event_sptr& _event ); | ||
bool wait_predicate() const; | ||
bool wait_stop_condition() const; | ||
void work(); | ||
|
||
//!\brief Sends a priority (internal) event and add it in the front of the event list, so it will be processed before other events. | ||
//!\return void | ||
virtual void on_event( const event_sptr& _event ) SX_OVERRIDE; | ||
virtual void interrupt_impl() SX_OVERRIDE; | ||
|
||
|
||
state_machine_status status_; | ||
mutable sxe::mutex run_and_event_mutex_; | ||
sxe::condition_variable run_and_event_condition_; | ||
mutable sxe::condition_variable terminated_condition_; | ||
sxe::SX_UNIQUE_PTR< sxe::thread > worker_thread_; | ||
std::list<event_sptr> event_list_; | ||
}; | ||
|
||
|
||
} | ||
|
||
|
||
#endif |
Oops, something went wrong.