TaskRunner.hh

00001 //********************************************************************
00002 //*** Thread/TaskRunner.hh
00003 //*** Copyright (c) 2003-2009 by Markus Winand <mws@fatalmind.com>
00004 //*** $Id: TaskRunner.hh,v 1.19 2009-03-02 14:16:46 mws Exp $
00005 //********************************************************************
00006 /*
00007 This file is part of ResourcePool.
00008 
00009 ResourcePool is free software; you can redistribute it
00010 and/or modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2 of 
00012 the License, or (at your option) any later version.
00013 
00014 ResourcePool is distributed in the hope that it will be
00015 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00016 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with ResourcePool; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00022 02111-1307  USA */
00023 
00024 #ifndef INCLUDED_TASKRUNNER_HH
00025 #define INCLUDED_TASKRUNNER_HH
00026 
00027 #include "Thread.hh"
00028 
00029 //#include "Lock.hh"
00030 
00031 //#include "Thread/Synchronize.hh"
00032 
00033 #include "Thread/TaskRunnerInterface.hh"
00034 
00035 #include "Exceptions/Exception.hh"
00036 #include "mm/gc_ptr.hh"
00037 
00038 #include "mm/CommonPtr.hh"
00039 
00040 namespace fatalmind {
00041 
00042 /* forward decl */
00043 
00044 class TaskRunnerTask;
00045 
00046 class TaskRunner: public Thread, public TaskRunnerInterface {
00047     public:
00048         TaskRunner();
00049         virtual ~TaskRunner();
00050 
00051         using TaskRunnerInterface::runDetached;
00052         void runDetached(CommonPtr<Task, MultiThreadedModel<> >);
00053 
00054         using TaskRunnerInterface::run;
00055         TaskRunnerInterface::ID run(CommonPtr<Task, MultiThreadedModel<> >);
00056 
00057         void stop();
00058 
00059         class Stopped: public Exception {
00060             public:
00061                 Stopped(string msg);
00062         };
00063 
00064     private:
00065         TaskRunner(TaskRunner&); // c-ctor is hidden
00066 
00067         gc_ptr<TaskRunnerTask, MultiThreadedModel<> > _tsk;
00068 };
00069 
00070 } //namespace fatalmind
00071 
00072 #endif

Generated on Mon Nov 9 16:21:24 2009 for ResourcePool by  doxygen 1.5.3