Changeset 16731 for trunk/FACT++


Ignore:
Timestamp:
06/05/13 21:16: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/fscctrl.cc

    r15443 r16731  
    55#include "Shell.h"
    66#include "StateMachineDim.h"
     7#include "StateMachineAsio.h"
    78#include "Connection.h"
    89#include "LocalControl.h"
     
    716717
    717718template <class T, class S>
    718 class StateMachineFSC : public T, public ba::io_service, public ba::io_service::work
     719class StateMachineFSC : public StateMachineAsio<T>
    719720{
    720721private:
     
    726727        fFSC.PostClose(false);
    727728
    728         /*
    729          // Now wait until all connection have been closed and
    730          // all pending handlers have been processed
    731          poll();
    732          */
    733 
    734729        return T::GetCurrentState();
    735730    }
     
    742737        // Now wait until all connection have been closed and
    743738        // all pending handlers have been processed
    744         poll();
     739        ba::io_service::poll();
    745740
    746741        if (evt.GetBool())
     
    755750    int Execute()
    756751    {
    757         // Dispatch (execute) at most one handler from the queue. In contrary
    758         // to run_one(), it doesn't wait until a handler is available
    759         // which can be dispatched, so poll_one() might return with 0
    760         // handlers dispatched. The handlers are always dispatched/executed
    761         // synchronously, i.e. within the call to poll_one()
    762         poll_one();
    763 
    764752        return fFSC.IsConnected() ? State::kConnected : State::kDisconnected;
    765753    }
     
    798786public:
    799787    StateMachineFSC(ostream &out=cout) :
    800         T(out, "FSC_CONTROL"), ba::io_service::work(static_cast<ba::io_service&>(*this)),
    801         fFSC(*this, *this)
    802     {
    803         // ba::io_service::work is a kind of keep_alive for the loop.
    804         // It prevents the io_service to go to stopped state, which
    805         // would prevent any consecutive calls to run()
    806         // or poll() to do nothing. reset() could also revoke to the
    807         // previous state but this might introduce some overhead of
    808         // deletion and creation of threads and more.
    809 
     788        StateMachineAsio<T>(out, "FSC_CONTROL"), fFSC(*this, *this)
     789    {
    810790        // State names
    811791        T::AddStateName(State::kDisconnected, "Disconnected",
Note: See TracChangeset for help on using the changeset viewer.