Changeset 16729 for trunk/FACT++


Ignore:
Timestamp:
06/05/13 20:47:44 (11 years ago)
Author:
tbretz
Message:
Make use of the new StateMachineAsio which gets the CPU consumption to basically 0 by a more intelligent event management.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/temperature.cc

    r16469 r16729  
    33#endif
    44
    5 #include <boost/bind.hpp>
    65#include <boost/array.hpp>
    76
     
    1514#include "Event.h"
    1615#include "StateMachineDim.h"
     16#include "StateMachineAsio.h"
    1717#include "Connection.h"
    1818#include "LocalControl.h"
     
    319319
    320320template <class T, class S>
    321 class StateMachinePowerControl : public T, public ba::io_service, public ba::io_service::work
     321class StateMachinePowerControl : public StateMachineAsio<T>
    322322{
    323323private:
     
    358358    int Execute()
    359359    {
    360         // Dispatch (execute) at most one handler from the queue. In contrary
    361         // to run_one(), it doesn't wait until a handler is available
    362         // which can be dispatched, so poll_one() might return with 0
    363         // handlers dispatched. The handlers are always dispatched/executed
    364         // synchronously, i.e. within the call to poll_one()
    365         poll_one();
    366 
    367360        return fPower.GetState();
    368361    }
     
    371364public:
    372365    StateMachinePowerControl(ostream &out=cout) :
    373         T(out, "TEMPERATURE"), ba::io_service::work(static_cast<ba::io_service&>(*this)),
    374         fPower(*this, *this)
    375     {
    376         // ba::io_service::work is a kind of keep_alive for the loop.
    377         // It prevents the io_service to go to stopped state, which
    378         // would prevent any consecutive calls to run()
    379         // or poll() to do nothing. reset() could also revoke to the
    380         // previous state but this might introduce some overhead of
    381         // deletion and creation of threads and more.
    382 
     366        StateMachineAsio<T>(out, "TEMPERATURE"), fPower(*this, *this)
     367    {
    383368        // State names
    384369        T::AddStateName(Temperature::State::kDisconnected, "NoConnection",
Note: See TracChangeset for help on using the changeset viewer.