Ignore:
Timestamp:
06/05/13 20:36:57 (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/lidctrl.cc

    r15122 r16727  
    1 #include <boost/bind.hpp>
    21#include <boost/array.hpp>
    32
     
    1211#include "Event.h"
    1312#include "StateMachineDim.h"
     13#include "StateMachineAsio.h"
    1414#include "Connection.h"
    1515#include "LocalControl.h"
     
    460460
    461461template <class T, class S>
    462 class StateMachineLidControl : public T, public ba::io_service, public ba::io_service::work
     462class StateMachineLidControl : public StateMachineAsio<T>
    463463{
    464464private:
     
    529529    int Execute()
    530530    {
    531         // Dispatch (execute) at most one handler from the queue. In contrary
    532         // to run_one(), it doesn't wait until a handler is available
    533         // which can be dispatched, so poll_one() might return with 0
    534         // handlers dispatched. The handlers are always dispatched/executed
    535         // synchronously, i.e. within the call to poll_one()
    536         poll_one();
    537 
    538531        const int rc = fLid.GetState();
    539532
     
    551544public:
    552545    StateMachineLidControl(ostream &out=cout) :
    553         T(out, "LID_CONTROL"), ba::io_service::work(static_cast<ba::io_service&>(*this)),
    554         fLid(*this, *this)
    555     {
    556         // ba::io_service::work is a kind of keep_alive for the loop.
    557         // It prevents the io_service to go to stopped state, which
    558         // would prevent any consecutive calls to run()
    559         // or poll() to do nothing. reset() could also revoke to the
    560         // previous state but this might introduce some overhead of
    561         // deletion and creation of threads and more.
    562 
     546        StateMachineAsio<T>(out, "LID_CONTROL"), fLid(*this, *this)
     547    {
    563548        // State names
    564549        T::AddStateName(Lid::State::kDisconnected, "NoConnection",
Note: See TracChangeset for help on using the changeset viewer.