DynExp
Highly flexible laboratory automation for dynamically changing experiments.
|
Module template for building gRPC servers listening on TCP sockets for network instruments to connect to. Network instruments derive from derived from DynExpInstr::gRPCInstrument. Derive from this class to build a gRPC server which controls a physical instrument based on gRPC remote procedure calls as e.g. issued by corresponding network instruments. More...
Classes | |
class | CallDataBase |
Base class for all TypedCallDataBase classes. Instances of this class manage the state of a single remote procedure call. More... | |
class | TypedCallDataBase |
Derive from this class to implement a single remote procedure call handled by this gRPC server gRPCModule . More... | |
Public Types | |
using | ParamsType = gRPCModuleParams< gRPCServices... > |
Type of the parameter class belonging to this Object type. Declare this alias in every derived class with the respective parameter class accompanying the derived Object . More... | |
using | ConfigType = gRPCModuleConfigurator< gRPCServices... > |
Type of the configurator class belonging to this Object type. Declare this alias in every derived class with the respective configurator class accompanying the derived Object . More... | |
using | ModuleDataType = gRPCModuleData< gRPCServices... > |
Type of the data class belonging to this ModuleBase type. Declare this alias in every derived class with the respective data class accompanying the derived ModuleBase . More... | |
Public Types inherited from DynExp::ModuleBase | |
using | ParamsType = ModuleParamsBase |
Type of the parameter class belonging to this Object type. Declare this alias in every derived class with the respective parameter class accompanying the derived Object . More... | |
using | ConfigType = ModuleConfiguratorBase |
Type of the configurator class belonging to this Object type. Declare this alias in every derived class with the respective configurator class accompanying the derived Object . More... | |
using | ModuleDataType = ModuleDataBase |
Type of the data class belonging to this ModuleBase type. Declare this alias in every derived class with the respective data class accompanying the derived ModuleBase . More... | |
using | ModuleDataTypeSyncPtrType = Util::SynchronizedPointer< ModuleDataType > |
Alias for the return type of ModuleBase::GetModuleData(). Data class instances wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way. More... | |
using | ModuleDataTypeSyncPtrConstType = Util::SynchronizedPointer< const ModuleDataType > |
Alias for the return type of ModuleBase::GetModuleData() const. Data class instances wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way. More... | |
using | ModuleDataGetterType = Util::CallableMemberWrapper< ModuleBase, ModuleDataTypeSyncPtrType(ModuleBase::*)(const std::chrono::milliseconds)> |
Invoking an instance of this alias is supposed to call ModuleBase::GetModuleData() of the instance the Util::CallableMemberWrapper has been constructed with. More... | |
Public Types inherited from DynExp::RunnableObject | |
using | ParamsType = RunnableObjectParams |
Type of the parameter class belonging to this Object type. Declare this alias in every derived class with the respective parameter class accompanying the derived Object . More... | |
using | ConfigType = RunnableObjectConfigurator |
Type of the configurator class belonging to this Object type. Declare this alias in every derived class with the respective configurator class accompanying the derived Object . More... | |
Public Types inherited from DynExp::Object | |
using | ParamsType = ParamsBase |
Type of the parameter class belonging to this Object type. Declare this alias in every derived class with the respective parameter class accompanying the derived Object . More... | |
using | ParamsTypeSyncPtrType = Util::SynchronizedPointer< ParamsType > |
Alias for the return type of Object::GetParams(). Parameters wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way. More... | |
using | ParamsConstTypeSyncPtrType = Util::SynchronizedPointer< const ParamsType > |
Alias for the return type of Object::GetParams() const. Parameters wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way. More... | |
using | ConfigType = ConfiguratorBase |
Type of the configurator class belonging to this Object type. Declare this alias in every derived class with the respective configurator class accompanying the derived Object . More... | |
using | ParamsGetterType = Util::CallableMemberWrapper< Object, decltype(&Object::GetParams)> |
Invoking an instance of this alias is supposed to call Object::GetParams() of the instance the Util::CallableMemberWrapper has been constructed with. More... | |
Public Member Functions | |
gRPCModule (const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params) | |
Constructs a ModuleBase instance. More... | |
virtual | ~gRPCModule ()=default |
virtual std::string | GetName () const override |
Returns the name of this Object type. More... | |
virtual std::string | GetCategory () const override |
Returns the category of this Object type. More... | |
bool | TreatModuleExceptionsAsWarnings () const override |
Determines whether this module should be terminated if an exception leaves the module's main loop or respective event handlers. More... | |
std::chrono::milliseconds | GetMainLoopDelay () const override final |
Specifies in which time intervals the module's event queue runs to handle pending events. More... | |
grpc::ServerCompletionQueue * | GetServerQueue () const noexcept |
Getter for the gRPC server's request queue. More... | |
template<size_t Index> | |
auto & | GetService () const noexcept |
Returns a reference to a service this gRPC server implements selected by the service index in the gRPCServices list. More... | |
template<typename T > | |
auto & | GetService () const noexcept |
Returns a reference to a service this gRPC server implements selected by the service type T . More... | |
Public Member Functions inherited from DynExp::ModuleBase | |
ModuleBase (const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params) | |
Constructs a ModuleBase instance. More... | |
virtual | ~ModuleBase ()=0 |
void | RestoreWindowStatesFromParams () |
RestoreWindowStatesFromParams() only calls RestoreWindowStatesFromParamsChild() . Override RestoreWindowStatesFromParamsChild() to restore the styles of possibly owned windows according to the style saved in the module's parameters. More... | |
void | UpdateParamsFromWindowStates () |
UpdateParamsFromWindowStates() only calls UpdateParamsFromWindowStatesChild() . Override UpdateParamsFromWindowStatesChild() to store the styles of possibly owned windows in the module's parameters. More... | |
ModuleDataTypeSyncPtrType | GetModuleData (const std::chrono::milliseconds Timeout=GetModuleDataTimeoutDefault) |
Locks the mutex of the module data class instance ModuleData assigned to this ModuleBase instance and returns a pointer to the locked ModuleData. Module data should not be locked by having called this function while subsequently calling a derived module's method which also makes use of the module's data by locking it. If this happens, the module data's mutex is locked recursively. In principle, this does no harm since Util::ISynchronizedPointerLockable supports that. But, it is not considered good practice. More... | |
ModuleDataTypeSyncPtrConstType | GetModuleData (const std::chrono::milliseconds Timeout=GetModuleDataTimeoutDefault) const |
Locks the mutex of the module data class instance ModuleData assigned to this ModuleBase instance and returns a pointer to the locked ModuleData. Module data should not be locked by having called this function while subsequently calling a derived module's method which also makes use of the module's data by locking it. If this happens, the module data's mutex is locked recursively. In principle, this does no harm since Util::ISynchronizedPointerLockable supports that. But, it is not considered good practice. More... | |
void | EnqueueEvent (ModuleDataBase::EventPtrType &&Event) const |
Enqueues Event at the module event queue's back. Takes ownership of the event. Notifies the module owning the respective ModuleDataBase's instance that a new event has been enqueued. More... | |
template<typename ReceiverType , typename EventType , typename... ArgsTs> | |
void | MakeAndEnqueueEvent (ReceiverType *Receiver, EventType EventFuncPtr, ArgsTs &&...Args) const |
Calls MakeEvent() to construct a new event and subsequently enqueues the event into the module's event queue. Logical const-ness: this is a const member function to allow pointers to const ModuleBase inserting events into the module's event queue. These kind of pointers are e.g. returned by RunnableInstance::GetOwner() which can be called by events' EventBase::InvokeChild() functions. For const ModuleBase* , it is possible to insert events into the event queue, but not to change the ModuleBase object itself (e.g. calling Object::Reset()). More... | |
virtual bool | HasUI () const noexcept |
Determines whether this module possesses a user interface (UI) which is shown in a window dedicated to the module. More... | |
Public Member Functions inherited from DynExp::RunnableObject | |
RunnableObject (const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params) | |
Constructs an Object instance. More... | |
virtual | ~RunnableObject ()=0 |
void | SetPaused (bool Pause, std::string Description="") |
Pauses or resumes a RunnableObject instance. Its thread stays running, but the instance does not perform any action while it is paused. More... | |
bool | IsRunning () const noexcept |
Returns Running. More... | |
bool | IsPaused () const noexcept |
Returns Paused. More... | |
bool | IsExiting () const noexcept |
Returns ShouldExit. More... | |
auto | GetStartupType () const noexcept |
Returns Startup. More... | |
auto | GetReasonWhyPaused () const |
Returns ReasonWhyPaused. More... | |
bool | Run (QWidget *ParentWidget=nullptr) |
Starts the RunnableObject instance's thread and ensures that all Object instances linked to this instance via ObjectLink parameters are in a ready state. Calls RunChild() which is to be overridden by derived classes to start a thread and to pass this thread back by calling StoreThread() . More... | |
bool | RunIfRunAutomatic () |
Calls Run() if RunnableObjectParams::Startup is set to RunnableObjectParams::Automatic. More... | |
bool | RunIfRunOnCreation () |
Calls Run() if RunnableObjectParams::Startup is set to RunnableObjectParams::OnCreation. More... | |
void | Terminate (bool Force=false, const std::chrono::milliseconds Timeout=TerminateTimeoutDefault) |
Notifies the RunnableObject instance's thread to terminate and waits until it has ended. Calls TerminateImpl(). More... | |
Public Member Functions inherited from Util::INonCopyable | |
INonCopyable (const INonCopyable &)=delete | |
INonCopyable & | operator= (const INonCopyable &)=delete |
Public Member Functions inherited from DynExp::Object | |
ItemIDType | GetID () const noexcept |
Returns the ID of this Object instance. Thread-safe since ID is const. More... | |
std::string | GetCategoryAndName () const |
Builds a string from an Object's category and name to allow the user to identify an Object's type. More... | |
void | EnsureReadyState (bool IsAutomaticStartup) |
Ensures that this Object instance is ready by possibly starting its worker thread or by opening connections to hardware devices. More... | |
void | CheckLinkedObjectStates () const |
Checks whether Object instances this instance uses are in a ready state. Override CheckLinkedObjectStatesChild() to implement this behavior. More... | |
void | Reset () |
Resets this Object instance (including all its derived classes) by calling ResetImpl() . A reset implies that the derived classes reload all their parameters from Params and that all LinkedObjectWrapper instances owned by this Object instance become invalidated. More... | |
void | BlockIfUnused (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) |
Blocks this Object instance setting Object::IsBlocked to true. Refer to Object::IsBlocked for the consequences. More... | |
ParamsConstTypeSyncPtrType | GetParams (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const |
Locks the mutex of the parameter class instance Params assigned to this Object instance and returns a pointer to the locked Params. More... | |
ParamsTypeSyncPtrType | GetParams (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) |
Locks the mutex of the parameter class instance Params assigned to this Object instance and returns a pointer to the locked Params. More... | |
auto | GetObjectName (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const |
Returns the name of this Object instance. More... | |
bool | IsSharedUsageEnabled (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const |
Returns whether shared usage has been enabled for this Object instance. Refer to ParamsBase::UsageType. More... | |
void | SetWarning (std::string Description, int ErrorCode) const |
Setter for Object::Warning. Sets the warning by a description and an error code. More... | |
void | SetWarning (const Util::Exception &e) const |
Setter for Object::Warning. Sets the warning by retrieving the warning data from an exception e . More... | |
void | ClearWarning () const |
Resets Object::Warning. More... | |
auto | GetWarning () const |
Returns Object::Warning in a thread-safe way by copying its internal data. More... | |
std::exception_ptr | GetException (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const |
Returns a pointer to the exception which has caused this Object instance to fail. More... | |
bool | IsReady () const |
Returns wheter this Object instance is ready (e.g. it is running or connected to a hardware device) and not blocked (refer to Object::IsBlocked). More... | |
auto | GetUseCount (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const |
Counts the registered useres in a thread-safe way. More... | |
bool | IsUnused (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const |
Returns whether this Object instance is used by other instances. More... | |
auto | GetUserIDs (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const |
Returns a list of the IDs of the registered users in a thread-safe way. More... | |
auto | GetUserNamesString (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const |
Builds a string describing which users are registered containing their object names, categories and type names in a thread-safe way. More... | |
Static Public Member Functions | |
constexpr static auto | Name () noexcept |
Every derived class has to redefine this function. More... | |
constexpr static auto | Category () noexcept |
Every derived class has to redefine this function. More... | |
Static Public Member Functions inherited from DynExp::ModuleBase | |
constexpr static auto | Category () noexcept |
Every derived class has to redefine this function. More... | |
Static Public Member Functions inherited from DynExp::Object | |
static std::string | CategoryAndNameToStr (const std::string &Category, const std::string &Name) |
Builds a string from an Object's category and name to allow the user to identify an Object's type. More... | |
Private Types | |
template<typename gRPCService > | |
using | ServicePtrType = std::unique_ptr< typename gRPCService::AsyncService > |
Alias for a pointer to a gRPC service. More... | |
Private Member Functions | |
auto | MakeServicePtrTuple () |
Constructs the gRPC services (gRPCServices ) this gRPC server implements and packs them as a tuple. More... | |
Util::DynExpErrorCodes::DynExpErrorCodes | ModuleMainLoop (DynExp::ModuleInstance &Instance) override final |
Module main loop. The function is executed periodically by the module thread. Also refer to GetMainLoopDelay() . More... | |
void | ResetImpl (dispatch_tag< ModuleBase >) override final |
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every derived class gets called - starting from DynExp::Object, descending the inheritance hierarchy. More... | |
virtual void | ResetImpl (DynExp::Object::dispatch_tag< gRPCModule >) |
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every derived class gets called - starting from DynExp::Object, descending the inheritance hierarchy. More... | |
void | OnErrorChild (DynExp::ModuleInstance &Instance) const override final |
This handler gets called just before the module thread terminates due to an exception. Override OnErrorChild() to perform shutdown and cleanup actions. More... | |
void | Shutdown () const |
Shuts down the gRPC server Server and its request queue ServerQueue. Then, it calls DrainServerQueue() to remove pending requests. More... | |
void | DrainServerQueue () const |
Empties ServerQueue removing every request and deleting associated CallDataBase instances. More... | |
Override | |
Override by derived classes. | |
virtual void | CreateInitialCallDataObjectsImpl (DynExp::Object::dispatch_tag< gRPCModule >, DynExp::ModuleInstance &Instance) const =0 |
Override by derived classes to let them call TypedCallDataBase::MakeCall of the TypedCallDataBase types they are providing. This creates initial listeners awaiting respective remote procedure calls from a client. Using tag dispatch mechanism (refer to DynExp::ParamsBase::dispatch_tag) to ensure that CreateInitialCallDataObjectsImpl() of every derived class gets called - starting from gRPCModule , descending the inheritance hierarchy. This allows every derived class to call TypedCallDataBase::MakeCall for their TypedCallDataBase types. More... | |
virtual void | OnInitChild (DynExp::ModuleInstance *Instance) const |
Allows derived classes to lock instruments they are controlling (e.g. with calls to DynExp::RunnableInstance::LockObject()) and to perform additional initialization steps. More... | |
virtual void | OnExitChild (DynExp::ModuleInstance *Instance) const |
Allows derived classes to unlock instruments they are controlling (e.g. with calls to DynExp::RunnableInstance::UnlockObject() and to perform additional cleanup steps. More... | |
Events | |
Event functions running in the module thread. | |
void | OnInit (DynExp::ModuleInstance *Instance) const override final |
This event is triggered right before the module thread starts. Override it to lock instruments this module depends on (via RunnableInstance::LockObject()) and to register/subscribe for events (via InterModuleEvent::Register()). More... | |
void | OnExit (DynExp::ModuleInstance *Instance) const override final |
This event is triggered right before the module thread terminates (not due to an exception, in this case refer to ModuleBase::OnError). Override it to unlock instruments this module depends on (via RunnableInstance::UnlockObject()) and to deregister/unsubscribe from events (via InterModuleEvent::Deregister()). More... | |
Private Attributes | |
std::unique_ptr< grpc::ServerCompletionQueue > | ServerQueue |
Queue holding the pending requests made to the gRPC server Server. More... | |
std::unique_ptr< grpc::Server > | Server |
Pointer to the actual gRPC server. More... | |
std::tuple< ServicePtrType< gRPCServices >... > | ServicePtrs |
Tuple of pointers to all the services this gRPC server implements. More... | |
std::atomic< bool > | ServerRunning |
Indicates whether Server is running. More... | |
Additional Inherited Members | |
Public Attributes inherited from DynExp::ModuleBase | |
ModuleThreadOnlyType | ModuleThreadOnly |
Allow exclusive access to some of ModuleBase's private methods to the module thread ModuleThreadMain() . More... | |
EventListenersOnlyType | EventListenersOnly |
Allow exclusive access to some of ModuleBase's private methods to any TypedEventListeners class. More... | |
Public Attributes inherited from DynExp::RunnableObject | |
RunnableInstanceOnlyType | RunnableInstanceOnly |
Allow exclusive access to some of RunnableObject's private methods to class RunnableInstance . More... | |
Public Attributes inherited from DynExp::Object | |
LinkedObjectWrapperOnlyType | LinkedObjectWrapperOnly |
Allow exclusive access to some of Object's private methods to any LinkedObjectWrapper<T>. More... | |
Static Public Attributes inherited from DynExp::ModuleBase | |
static constexpr auto | GetModuleDataTimeoutDefault = std::chrono::milliseconds(1000) |
Determines the default timeout for GetModuleData() to lock the mutex synchronizing the module's data ModuleData. More... | |
Static Public Attributes inherited from DynExp::RunnableObject | |
static constexpr auto | ShortTimeoutDefault = std::chrono::milliseconds(50) |
Default timeout e.g. used as a default for calls to InstrumentBase::GetInstrumentData or ModuleBase::GetModuleData. More... | |
static constexpr auto | TerminateTimeoutDefault = std::chrono::milliseconds(3000) |
Default timeout used as a default for calls to RunnableObject::Terminate. More... | |
Static Public Attributes inherited from DynExp::Object | |
static constexpr std::chrono::milliseconds | GetParamsTimeoutDefault = std::chrono::milliseconds(100) |
Default timeout used by Object::GetParams() to lock the mutex of the parameter instance assigned to this Object instance. More... | |
Protected Member Functions inherited from DynExp::RunnableObject | |
void | Init () |
Initializes member variables in case of a reset. More... | |
std::promise< void > | MakeThreadExitedPromise () |
Helper function to be used by overridden RunChild() functions in derived classes to (re)initialize the ThreadExitedSignal future and to provide the derived class a promise to signal the RunnableObject instance that its thread has terminated. More... | |
void | StoreThread (std::thread &&Thread) noexcept |
Stores a thread constructed by a derived class overriding RunChild() in Thread taking ownership of the thread. Only call this function within RunChild()! More... | |
bool | IsCallFromRunnableThread () const |
Checks whether Thread's id matches the id of the calling thread. This is thread-safe if the function is called by the RunnableObject instance's thread since Terminate() joins the threads before changing the Thread member. It is also thread-safe if the function is called by the thread owning the the RunnableObject instance since Run() and Terminate() can only be called by this thread. Only Run() and Terminate() (indirectly) modify Thread . More... | |
void | EnsureCallFromRunnableThread () const |
Asserts that the call to this function is performed from the RunnableObject instance's thread by calling IsCallFromRunnableThread(). More... | |
void | SetReasonWhyPaused (std::string Description) |
Sets the reason why this RunnableObject instance has been paused. More... | |
void | SetReasonWhyPaused (const Util::Exception &e) |
Sets the reason why this RunnableObject instance has been paused. More... | |
void | ClearReasonWhyPaused () |
Removes the reason why this RunnableObject instance has been paused (since it is resumed). More... | |
Protected Member Functions inherited from Util::INonCopyable | |
constexpr | INonCopyable ()=default |
~INonCopyable ()=default | |
Protected Member Functions inherited from DynExp::Object | |
Object (const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params) | |
Constructs an Object instance. More... | |
virtual | ~Object ()=0 |
void | EnsureCallFromOwningThread () const |
Asserts that the call to this function is performed from the thread which constructed this Object instance (the thread with the id stored in Object::OwnerThreadID). More... | |
ParamsTypeSyncPtrType | GetNonConstParams (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const |
Allows derived Objects to edit their own parameters - even in const task functions (for instruments) or event functions (for modules). More... | |
auto | LockUserList (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) |
Locks the user list for thread-safe manipulation. More... | |
void | DeregisterAllUnsafe () |
Deregisters all users and notifies them that they need to check the states of their used linked objects. More... | |
auto | GetUseCountUnsafe () |
auto | GetUserNamesStringUnsafe () const |
bool | IsUnusedUnsafe () |
Returns whether this Object instance is used by other instances (not thread-safe). More... | |
Static Protected Member Functions inherited from DynExp::ModuleBase | |
static auto | GetExceptionUnsafe (const ModuleDataTypeSyncPtrConstType &ModuleDataPtr) |
Getter for ModuleDataBase::ModuleException assuming that the module data has already been locked. More... | |
Module template for building gRPC servers listening on TCP sockets for network instruments to connect to. Network instruments derive from derived from DynExpInstr::gRPCInstrument. Derive from this class to build a gRPC server which controls a physical instrument based on gRPC remote procedure calls as e.g. issued by corresponding network instruments.
...gRPCServices | List of gRPC service types this gRPC server implements. The order of service types should match the order of stub types in the gRPCStubs list of the respective DynExpInstr::gRPCInstrument network instrument. |
Definition at line 115 of file gRPCModule.h.
using DynExpModule::gRPCModule< gRPCServices >::ConfigType = gRPCModuleConfigurator<gRPCServices...> |
Type of the configurator class belonging to this Object
type. Declare this alias in every derived class with the respective configurator class accompanying the derived Object
.
Definition at line 126 of file gRPCModule.h.
using DynExpModule::gRPCModule< gRPCServices >::ModuleDataType = gRPCModuleData<gRPCServices...> |
Type of the data class belonging to this ModuleBase
type. Declare this alias in every derived class with the respective data class accompanying the derived ModuleBase
.
Definition at line 127 of file gRPCModule.h.
using DynExpModule::gRPCModule< gRPCServices >::ParamsType = gRPCModuleParams<gRPCServices...> |
Type of the parameter class belonging to this Object
type. Declare this alias in every derived class with the respective parameter class accompanying the derived Object
.
Definition at line 125 of file gRPCModule.h.
|
private |
Alias for a pointer to a gRPC service.
gRPCService | gRPC service type the pointer points to |
Definition at line 122 of file gRPCModule.h.
|
inline |
Constructs a ModuleBase
instance.
OwnerThreadID | Thread id of the thread owning the Object instance to be constructed. |
Params | Parameter class instance to be assigned to the Object instance to be constructed. |
Util::InvalidArgException | is thrown if OwnerThreadID is an invalid thread id or if Params is nullptr. |
Util::InvalidArgException | is thrown if ModuleParamsBase::ModuleData of Params is nullptr. |
Definition at line 135 of file gRPCModule.h.
|
virtualdefault |
|
inlinestaticconstexprnoexcept |
Every derived class has to redefine this function.
Definition at line 130 of file gRPCModule.h.
|
privatepure virtual |
Override by derived classes to let them call TypedCallDataBase::MakeCall of the TypedCallDataBase
types they are providing. This creates initial listeners awaiting respective remote procedure calls from a client. Using tag dispatch mechanism (refer to DynExp::ParamsBase::dispatch_tag) to ensure that CreateInitialCallDataObjectsImpl()
of every derived class gets called - starting from gRPCModule
, descending the inheritance hierarchy. This allows every derived class to call TypedCallDataBase::MakeCall for their TypedCallDataBase
types.
Instance | Handle to the module thread's data |
|
inlineprivate |
Empties ServerQueue removing every request and deleting associated CallDataBase
instances.
Definition at line 554 of file gRPCModule.h.
|
inlineoverridevirtual |
Returns the category of this Object
type.
Reimplemented from DynExp::ModuleBase.
Definition at line 142 of file gRPCModule.h.
|
inlinefinaloverridevirtual |
Specifies in which time intervals the module's event queue runs to handle pending events.
std::chrono::milliseconds::max()
to make the module thread only wake up to execute the module main loop (after handling enqueued events) when an event is enqueued. Return 0 to make the module main loop execute as fast as possible.Be fast answering requests. Return to main loop regularly to handle e.g. a request that the module should terminate.
Reimplemented from DynExp::ModuleBase.
Definition at line 155 of file gRPCModule.h.
|
inlineoverridevirtual |
Returns the name of this Object
type.
Implements DynExp::Object.
Reimplemented in DynExpModule::NetworkTimeTaggerT< gRPCServices >, DynExpModule::NetworkDigitalOutT< gRPCServices >, DynExpModule::NetworkDigitalInT< gRPCServices >, DynExpModule::NetworkDataStreamInstrumentT< gRPCServices >, DynExpModule::NetworkDataStreamInstrumentT< gRPCServices... >, DynExpModule::NetworkAnalogOutT< gRPCServices >, and DynExpModule::NetworkAnalogInT< gRPCServices >.
Definition at line 141 of file gRPCModule.h.
|
inlinenoexcept |
Getter for the gRPC server's request queue.
Definition at line 161 of file gRPCModule.h.
|
inlinenoexcept |
Returns a reference to a service this gRPC server implements selected by the service index in the gRPCServices
list.
Index | Index of the service pointer to return |
Index
from ServicePtrs Definition at line 170 of file gRPCModule.h.
|
inlinenoexcept |
Returns a reference to a service this gRPC server implements selected by the service type T
.
T | Type of the service to return |
ServicePtrType
pointing to the service type T
(as contained in ServicePtrs) Definition at line 180 of file gRPCModule.h.
|
inlineprivate |
Constructs the gRPC services (gRPCServices
) this gRPC server implements and packs them as a tuple.
Definition at line 413 of file gRPCModule.h.
|
inlinefinaloverrideprivatevirtual |
Module main loop. The function is executed periodically by the module thread. Also refer to GetMainLoopDelay()
.
Instance | Handle to the module thread's data |
Implements DynExp::ModuleBase.
Definition at line 418 of file gRPCModule.h.
|
inlinestaticconstexprnoexcept |
Every derived class has to redefine this function.
Definition at line 129 of file gRPCModule.h.
|
inlinefinaloverrideprivatevirtual |
This handler gets called just before the module thread terminates due to an exception. Override OnErrorChild()
to perform shutdown and cleanup actions.
Instance | Handle to the module thread's data |
Reimplemented from DynExp::ModuleBase.
Definition at line 531 of file gRPCModule.h.
|
inlinefinaloverrideprivatevirtual |
This event is triggered right before the module thread terminates (not due to an exception, in this case refer to ModuleBase::OnError). Override it to unlock instruments this module depends on (via RunnableInstance::UnlockObject()) and to deregister/unsubscribe from events (via InterModuleEvent::Deregister()).
Instance | Handle to the module thread's data |
Calls OnExitChild()
before shutting down the gRPC server calling Shutdown()
.
Reimplemented from DynExp::ModuleBase.
Definition at line 519 of file gRPCModule.h.
|
inlineprivatevirtual |
Allows derived classes to unlock instruments they are controlling (e.g. with calls to DynExp::RunnableInstance::UnlockObject() and to perform additional cleanup steps.
Instance | Handle to the module thread's data |
Reimplemented in DynExpModule::NetworkDataStreamInstrumentT< gRPCServices >, and DynExpModule::NetworkDataStreamInstrumentT< gRPCServices... >.
Definition at line 478 of file gRPCModule.h.
|
inlinefinaloverrideprivatevirtual |
This event is triggered right before the module thread starts. Override it to lock instruments this module depends on (via RunnableInstance::LockObject()) and to register/subscribe for events (via InterModuleEvent::Register()).
Instance | Handle to the module thread's data |
Initializes and starts the gRPC server. Then, calls CreateInitialCallDataObjectsImpl()
to create listeners awaiting remote procedure calls and OnInitChild()
to let derived classes lock the instruments they are controlling.
Reimplemented from DynExp::ModuleBase.
Definition at line 491 of file gRPCModule.h.
|
inlineprivatevirtual |
Allows derived classes to lock instruments they are controlling (e.g. with calls to DynExp::RunnableInstance::LockObject()) and to perform additional initialization steps.
Instance | Handle to the module thread's data |
Reimplemented in DynExpModule::NetworkDataStreamInstrumentT< gRPCServices >, and DynExpModule::NetworkDataStreamInstrumentT< gRPCServices... >.
Definition at line 471 of file gRPCModule.h.
|
inlinefinaloverrideprivate |
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl()
of every derived class gets called - starting from DynExp::Object, descending the inheritance hierarchy.
Definition at line 434 of file gRPCModule.h.
|
inlineprivatevirtual |
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl()
of every derived class gets called - starting from DynExp::Object, descending the inheritance hierarchy.
Definition at line 448 of file gRPCModule.h.
|
inlineprivate |
Shuts down the gRPC server Server and its request queue ServerQueue. Then, it calls DrainServerQueue()
to remove pending requests.
Definition at line 540 of file gRPCModule.h.
|
inlineoverridevirtual |
Determines whether this module should be terminated if an exception leaves the module's main loop or respective event handlers.
If an error occurs during server initialization, terminate the module.
Reimplemented from DynExp::ModuleBase.
Definition at line 148 of file gRPCModule.h.
|
mutableprivate |
Pointer to the actual gRPC server.
Definition at line 579 of file gRPCModule.h.
|
mutableprivate |
Queue holding the pending requests made to the gRPC server Server.
Definition at line 574 of file gRPCModule.h.
|
mutableprivate |
Indicates whether Server is running.
Definition at line 589 of file gRPCModule.h.
|
private |
Tuple of pointers to all the services this gRPC server implements.
Definition at line 584 of file gRPCModule.h.