AceSmartSoft API Documentation
Public Types | Public Member Functions | List of all members
SmartACE::ThreadQueueQueryHandler< RequestType, AnswerType > Class Template Reference

Decorator for QueryServerHandler to defer handling to another thread. More...

#include <smartProcessingPatterns.hh>

Inheritance diagram for SmartACE::ThreadQueueQueryHandler< RequestType, AnswerType >:
SmartACE::Task

Public Types

using IQueryServerHandlerPtr = std::shared_ptr< Smart::IQueryServerHandler< RequestType, AnswerType > >
 

Public Member Functions

virtual int start () override
 Creates and starts a new thread (if not yet started) More...
 
virtual int stop (const bool wait_till_stopped=true) override
 Closes currently active thread (if it was started before) More...
 
 ThreadQueueQueryHandler (Smart::IComponent *component, IQueryServerHandlerPtr inner_handler_ptr)
 Create a new threaded QueryServerHandler Decorator. More...
 
virtual ~ThreadQueueQueryHandler ()
 
- Public Member Functions inherited from SmartACE::Task
 Task (Smart::IComponent *component=0)
 Constructor. More...
 
virtual ~Task ()
 Destructor. More...
 
virtual int start (const ACE_Sched_Params &sched_params, const int &cpuAffinity=-1)
 control method to start the internal thread using given scheduling parameters More...
 

Additional Inherited Members

- Protected Member Functions inherited from SmartACE::Task
virtual bool test_canceled ()
 Tests whether the thread has been signaled to stop. More...
 
virtual void sleep_for (const Smart::Duration &rel_time)
 Blocks execution of the calling thread during the span of time specified by rel_time. More...
 
virtual int svc (void)
 implements ACE_Task<ACE_MT_SYNCH> More...
 
int setCpuAffinity (const int &cpuCore)
 
int setSchedParams (const ACE_Sched_Params &sched_params)
 

Detailed Description

template<class RequestType, class AnswerType>
class SmartACE::ThreadQueueQueryHandler< RequestType, AnswerType >

Decorator for QueryServerHandler to defer handling to another thread.

This Decorator (see Design Patterns by Gamma et. al) can be used if a QueryServerHandler is slow and/or blocking and would therefore block the framework. This handler is an active object and has a single thread, in which the Queries are handled one after another.

example usage:

MySlowQueryHandler: public QueryServerHandler<R,A>
{
...
};
...
MySlowQueryHandler slowHandler;
ThreadQueueQueryHandler<R,A> threadedHandler(slowHandler);
QueryServer queryService<R,A>(component,"heavy_computation", threadedHandler);

Member Typedef Documentation

◆ IQueryServerHandlerPtr

template<class RequestType , class AnswerType >
using SmartACE::ThreadQueueQueryHandler< RequestType, AnswerType >::IQueryServerHandlerPtr = std::shared_ptr<Smart::IQueryServerHandler<RequestType,AnswerType> >

Constructor & Destructor Documentation

◆ ThreadQueueQueryHandler()

template<class RequestType , class AnswerType >
SmartACE::ThreadQueueQueryHandler< RequestType, AnswerType >::ThreadQueueQueryHandler ( Smart::IComponent *  component,
IQueryServerHandlerPtr  inner_handler_ptr 
)
inline

Create a new threaded QueryServerHandler Decorator.

The internal handling thread is started/stopped automatically.

Parameters
componentthe pointer to the surrounding component
inner_handler_ptrwhich will be called in a separate thread.

◆ ~ThreadQueueQueryHandler()

template<class RequestType , class AnswerType >
virtual SmartACE::ThreadQueueQueryHandler< RequestType, AnswerType >::~ThreadQueueQueryHandler ( )
inlinevirtual

Member Function Documentation

◆ start()

template<class RequestType , class AnswerType >
virtual int SmartACE::ThreadQueueQueryHandler< RequestType, AnswerType >::start ( )
inlineoverridevirtual

Creates and starts a new thread (if not yet started)

Reimplemented from SmartACE::Task.

◆ stop()

template<class RequestType , class AnswerType >
virtual int SmartACE::ThreadQueueQueryHandler< RequestType, AnswerType >::stop ( const bool  wait_till_stopped = true)
inlineoverridevirtual

Closes currently active thread (if it was started before)

Reimplemented from SmartACE::Task.


The documentation for this class was generated from the following file: