CppCMS
cppcms/thread_pool.h
00001 
00002 //                                                                             
00003 //  Copyright (C) 2008-2012  Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>     
00004 //                                                                             
00005 //  See accompanying file COPYING.TXT file for licensing details.
00006 //
00008 #ifndef CPPCMS_THREAD_POOL_H
00009 #define CPPCMS_THREAD_POOL_H
00010 
00011 #include <cppcms/defs.h>
00012 #include <booster/noncopyable.h>
00013 #include <booster/function.h>
00014 #include <booster/hold_ptr.h>
00015 
00016 namespace cppcms {
00017 
00018         namespace impl {
00019                 class thread_pool;
00020         }
00021 
00029         class CPPCMS_API thread_pool : public booster::noncopyable {
00030         public:
00031 
00036                 int post(booster::function<void()> const &job); 
00037 
00047                 bool cancel(int id);
00048 
00050                 thread_pool(int threads);
00051                 void stop();
00052                 ~thread_pool();
00054 
00055         private:
00056 
00057                 booster::hold_ptr<impl::thread_pool> impl_;
00058         };
00059 
00060 
00061 } // cppcms
00062 
00063 
00064 
00065 #endif
00066