2323 #include " react/logging/EventRecords.h"
2424#endif // REACT_ENABLE_LOGGING
2525
26+ // Include all engines for convenience
27+ #include " react/engine/PulsecountEngine.h"
28+ #include " react/engine/SubtreeEngine.h"
2629#include " react/engine/ToposortEngine.h"
2730
2831/* ****************************************/ REACT_BEGIN /* ****************************************/
@@ -62,14 +65,32 @@ class Reactor;
6265template <typename D, typename ... TValues>
6366class SignalPack ;
6467
68+ // /////////////////////////////////////////////////////////////////////////////////////////////////
69+ // / Common types & constants
70+ // /////////////////////////////////////////////////////////////////////////////////////////////////
6571using REACT_IMPL::TurnFlagsT;
6672
67- // ETurnFlags
73+ // ETurnFlags
74+ using REACT_IMPL::ETurnFlags;
6875using REACT_IMPL::allow_merging;
6976
7077#ifdef REACT_ENABLE_LOGGING
7178 using REACT_IMPL::EventLog;
72- #endif // REACT_ENABLE_LOGGING
79+ #endif // REACT_ENABLE_LOGGING
80+
81+ // Domain modes
82+ enum EDomainMode
83+ {
84+ sequential,
85+ sequential_concurrent,
86+ parallel,
87+ parallel_concurrent
88+ };
89+
90+ // Expose enum types so aliases for engines can be declared, but don't
91+ // expose the actual enum values as they are reserved for internal use.
92+ using REACT_IMPL::EInputMode;
93+ using REACT_IMPL::EPropagationMode;
7394
7495// /////////////////////////////////////////////////////////////////////////////////////////////////
7596// / TransactionStatus
@@ -131,10 +152,10 @@ class DomainBase
131152 REACT_IMPL::NodeUpdateTimerEnabled<typename Policy::Engine>::value;
132153
133154 static const bool is_concurrent =
134- REACT_IMPL::IsConcurrentEngine< typename Policy::Engine>::value ;
155+ Policy::input_mode == REACT_IMPL::concurrent_input ;
135156
136157 static const bool is_parallel =
137- REACT_IMPL::IsParallelEngine< typename Policy::Engine>::value ;
158+ Policy::propagation_mode == REACT_IMPL::parallel_propagation ;
138159
139160 // /////////////////////////////////////////////////////////////////////////////////////////////
140161 // / Aliases for reactives of this domain
@@ -350,15 +371,98 @@ auto MakeContinuation(const Events<D,E>& trigger,
350371/* **************************************/ REACT_IMPL_BEGIN /* *************************************/
351372
352373// /////////////////////////////////////////////////////////////////////////////////////////////////
353- // / Policy
374+ // / ModeSelector - Translate domain mode to individual propagation and input modes
375+ // /////////////////////////////////////////////////////////////////////////////////////////////////
376+ template <EDomainMode>
377+ struct ModeSelector ;
378+
379+ template <>
380+ struct ModeSelector <sequential>
381+ {
382+ static const EInputMode input = consecutive_input;
383+ static const EPropagationMode propagation = sequential_propagation;
384+ };
385+
386+ template <>
387+ struct ModeSelector <sequential_concurrent>
388+ {
389+ static const EInputMode input = concurrent_input;
390+ static const EPropagationMode propagation = sequential_propagation;
391+ };
392+
393+ template <>
394+ struct ModeSelector <parallel>
395+ {
396+ static const EInputMode input = consecutive_input;
397+ static const EPropagationMode propagation = parallel_propagation;
398+ };
399+
400+ template <>
401+ struct ModeSelector <parallel_concurrent>
402+ {
403+ static const EInputMode input = concurrent_input;
404+ static const EPropagationMode propagation = parallel_propagation;
405+ };
406+
407+ // /////////////////////////////////////////////////////////////////////////////////////////////////
408+ // / GetDefaultEngine - Get default engine type for given propagation mode
354409// /////////////////////////////////////////////////////////////////////////////////////////////////
410+ template <EPropagationMode>
411+ struct GetDefaultEngine ;
412+
413+ template <>
414+ struct GetDefaultEngine <sequential_propagation>
415+ {
416+ using Type = ToposortEngine<sequential_propagation>;
417+ };
418+
419+ template <>
420+ struct GetDefaultEngine <parallel_propagation>
421+ {
422+ using Type = SubtreeEngine<parallel_propagation>;
423+ };
424+
425+ // /////////////////////////////////////////////////////////////////////////////////////////////////
426+ // / EngineTypeBuilder - Instantiate the given template engine type with mode.
427+ // /////////////////////////////////////////////////////////////////////////////////////////////////
428+ template <EPropagationMode>
429+ struct DefaultEnginePlaceholder ;
430+
431+ // Concrete engine template type
355432template
356433<
357- typename TEngine = ToposortEngine<sequential>
434+ EPropagationMode mode,
435+ template <EPropagationMode> class TTEngine
436+ >
437+ struct EngineTypeBuilder
438+ {
439+ using Type = TTEngine<mode>;
440+ };
441+
442+ // Placeholder engine type - use default engine for given mode
443+ template
444+ <
445+ EPropagationMode mode
446+ >
447+ struct EngineTypeBuilder <mode,DefaultEnginePlaceholder>
448+ {
449+ using Type = typename GetDefaultEngine<mode>::Type;
450+ };
451+
452+ // /////////////////////////////////////////////////////////////////////////////////////////////////
453+ // / DomainPolicy
454+ // /////////////////////////////////////////////////////////////////////////////////////////////////
455+ template
456+ <
457+ EDomainMode mode,
458+ template <EPropagationMode> class TTEngine = DefaultEnginePlaceholder
358459>
359460struct DomainPolicy
360461{
361- using Engine = TEngine;
462+ static const EInputMode input_mode = ModeSelector<mode>::input;
463+ static const EPropagationMode propagation_mode = ModeSelector<mode>::propagation;
464+
465+ using Engine = typename EngineTypeBuilder<propagation_mode,TTEngine>::Type;
362466};
363467
364468// /////////////////////////////////////////////////////////////////////////////////////////////////
@@ -385,9 +489,10 @@ class DomainInitializer
385489// /////////////////////////////////////////////////////////////////////////////////////////////////
386490// / Domain definition macro
387491// /////////////////////////////////////////////////////////////////////////////////////////////////
388- #define REACTIVE_DOMAIN (name, ...) \
389- struct name : public REACT ::DomainBase<name, REACT_IMPL::DomainPolicy<__VA_ARGS__ >> {}; \
390- REACT_IMPL::DomainInitializer< name > name ## _initializer_;
492+ #define REACTIVE_DOMAIN (name, ...) \
493+ struct name : \
494+ public REACT::DomainBase<name, REACT_IMPL::DomainPolicy< __VA_ARGS__ >> {}; \
495+ REACT_IMPL::DomainInitializer<name> name ## _initializer_;
391496
392497// /////////////////////////////////////////////////////////////////////////////////////////////////
393498// / Define type aliases for given domain
0 commit comments