00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef RESOURCEPOOL_TASKRUNNER_TASKRUNNERPOOL_HH
00010 #define RESOURCEPOOL_TASKRUNNER_TASKRUNNERPOOL_HH
00011
00012 #include "mm/gc_ptr.hh"
00013 #include "mm/CommonPtr.hh"
00014
00015 #ifndef RESOURCEPOOL_RESOURCEPOOL_HH
00016 #include "ResourcePool/ResourcePool.hh"
00017 #endif
00018
00019 #ifndef INCLUDED_TASKRUNNER_HH
00020 #include "Thread/TaskRunner.hh"
00021 #endif
00022
00023 #include "Thread/TaskRunnerInterface.hh"
00024
00025 #ifndef RESOURCEPOOL_TASKRUNNER_RESOURCE_HH
00026 #include "Resource.hh"
00027 #endif
00028
00029 #ifndef RESOURCEPOOL_TASKRUNNER_FACTORY_HH
00030 #include "Factory.hh"
00031 #endif
00032
00033 #ifndef INCLUDED_THREAD_LOCK_HH
00034 #include "Thread/Lock.hh"
00035 #endif
00036
00037 #include "Thread/LockStatistics.hh"
00038
00039 namespace fatalmind {
00040
00041 namespace TaskRunnerPoolInternals {
00042 class CleanUpTask;
00043 class ReleaseTaskRunner;
00044 }
00045
00049 class TaskRunnerPool: public TaskRunnerInterface {
00050 public:
00051 TaskRunnerPool(
00052 const ResourcePoolOptions& = ResourcePoolOptions::defaultOptions
00053 );
00054 ~TaskRunnerPool();
00055
00056 using TaskRunnerInterface::runDetached;
00057 virtual void runDetached(CommonPtr<Task, MultiThreadedModel<> >);
00058
00059 using TaskRunnerInterface::run;
00060 TaskRunnerInterface::ID run(CommonPtr<Task, MultiThreadedModel<> >);
00061
00062 private:
00063 typedef fatalmind::PoolType<TaskRunnerPoolInternals::Factory
00064 , TaskRunnerPoolInternals::Resource
00065 , fatalmind::TaskRunner
00066 , NopCommand<TaskRunnerPoolInternals::Factory>
00067 , MultiThreadedModel<UsageOnlyLockStatistics> > TaskRunnerPool_t;
00068 typedef ResourcePool<TaskRunnerPool_t> pool_t;
00069
00070 TaskRunnerPool_t::factory_t _factory;
00071 pool_t _pool;
00072
00073
00074 private:
00075 void free(TaskRunnerPoolInternals::Resource&);
00076 friend
00077 class TaskRunnerPoolInternals::CleanUpTask;
00078 friend
00079 class TaskRunnerPoolInternals::ReleaseTaskRunner;
00080
00081
00082 private:
00083 TaskRunnerPool(const TaskRunnerPool&);
00084 TaskRunnerPool& operator=(const TaskRunnerPool&);
00085 };
00086
00087 }
00088 #endif
00089