PeriodicDispatchThread.cpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
00014 
00015 //----------------------------------------------------------------------
00022 //----------------------------------------------------------------------
00023 #include "icl_core_dispatch/PeriodicDispatchThread.h"
00024 
00025 #include "icl_core_dispatch/Operation.h"
00026 
00027 #include <boost/foreach.hpp>
00028 
00029 namespace icl_core {
00030 namespace dispatch {
00031 
00032 PeriodicDispatchThread::PeriodicDispatchThread(icl_core::String const & description,
00033                                                icl_core::TimeSpan const & period,
00034                                                ThreadPriority priority)
00035   : icl_core::thread::PeriodicThread(description, period, priority)
00036 {
00037 }
00038 
00039 PeriodicDispatchThread::~PeriodicDispatchThread()
00040 {
00041   stop();
00042   join();
00043 }
00044 
00045 void PeriodicDispatchThread::addOperation(Operation *op)
00046 {
00047   m_dispatch_queue.push_back(op);
00048 }
00049 
00050 void PeriodicDispatchThread::run()
00051 {
00052   while (execute())
00053   {
00054     BOOST_FOREACH (Operation *op, m_dispatch_queue)
00055     {
00056       op->execute();
00057     }
00058 
00059     if (execute())
00060     {
00061       waitPeriod();
00062     }
00063   }
00064 }
00065 
00066 }
00067 }


fzi_icl_core
Author(s):
autogenerated on Thu Jun 6 2019 20:22:24