From 58eb9ff4b82d416f6d13b5ac5eebd62972fa2436 Mon Sep 17 00:00:00 2001 From: Artyom Beilis Date: Thu, 13 May 2010 14:06:13 +0000 Subject: [PATCH] Replaced boost::shared_ptr with booster::shared_ptr --- CMakeLists.txt | 40 -------- application.cpp | 80 +++++++-------- application.h | 35 +++---- applications_pool.cpp | 44 ++++----- applications_pool.h | 12 +-- atomic_counter.cpp | 167 ------------------------------- atomic_counter.h | 94 ------------------ base_cache.h | 11 ++- cache_interface.h | 4 +- cache_over_ip.cpp | 12 +-- cache_over_ip.h | 6 +- cache_pool.cpp | 6 +- cache_pool.h | 4 +- cache_server_main.cpp | 2 +- cache_storage.cpp | 4 +- cache_storage.h | 6 +- cgi_acceptor.h | 4 +- cgi_api.cpp | 4 +- cgi_api.h | 8 +- connection_forwarder.cpp | 15 +-- fastcgi_api.cpp | 2 +- hello_world.cpp | 16 +-- http_api.cpp | 6 +- http_context.cpp | 12 +-- http_context.h | 14 +-- http_request.cpp | 11 +-- intrusive_ptr.h | 218 ----------------------------------------- logger.cpp | 5 +- refcounted.h | 63 ------------ rpc_json.cpp | 6 +- rpc_json.h | 14 +-- scgi_api.cpp | 2 +- service.cpp | 2 +- service_impl.h | 11 +-- session_api.h | 8 +- session_dual.cpp | 2 +- session_dual.h | 8 +- session_interface.h | 4 +- session_memory_storage.cpp | 2 +- session_memory_storage.h | 4 +- session_pool.cpp | 21 ++-- session_pool.h | 4 +- session_posix_file_storage.cpp | 2 +- session_posix_file_storage.h | 4 +- session_sid.cpp | 2 +- session_sid.h | 6 +- session_storage.h | 8 +- session_tcp_storage.cpp | 6 +- session_win32_file_storage.cpp | 2 +- session_win32_file_storage.h | 4 +- tcp_cache_server.cpp | 26 +++-- tcp_cache_server.h | 4 +- tests/cache_backend_test.cpp | 6 +- tests/forwarder_test.cpp | 15 +-- tests/proto_test.cpp | 2 +- tests/storage_test.cpp | 6 +- thread_pool.cpp | 7 +- url_dispatcher.cpp | 19 ++-- views_pool.cpp | 3 +- 59 files changed, 251 insertions(+), 864 deletions(-) delete mode 100644 atomic_counter.cpp delete mode 100644 atomic_counter.h delete mode 100644 intrusive_ptr.h delete mode 100644 refcounted.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 389f82e..9e0d4e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,42 +205,6 @@ set(CPPCMS_LIBRARY_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}) # Atomic API tests # -check_cxx_source_compiles( - "#include - int main() { volatile long v=0; return InterlockedCompareExchange(&v,1,0); }" - HAVE_WIN32_INTERLOCKED) - -check_cxx_source_compiles( - "int main() { volatile long v=0; return __sync_add_and_fetch(&v,1); }" - HAVE_SYNC_FETCH_AND_ADD) - -check_cxx_source_compiles( - "#include - using __gnu_cxx::__exchange_and_add; - int main(){ volatile int x=0; return __exchange_and_add(&x,1);}" - HAVE_GCC_BITS_EXCHANGE_AND_ADD) - -check_cxx_source_compiles( - "#include - using __gnu_cxx::__exchange_and_add; - int main(){ volatile int x=0; return __exchange_and_add(&x,1);}" - HAVE_GCC_EXT_EXCHANGE_AND_ADD) - -check_cxx_source_compiles( - "#include - #include - int main() { volatile unsigned v=0; return atomic_fetchadd_int(&v,1); }" - HAVE_FREEBSD_ATOMIC) - -check_cxx_source_compiles( - "#include - int main() { volatile unsigned v=0; return atomic_add_int_nv(&v,1); }" - HAVE_SOLARIS_ATOMIC) - -check_cxx_source_compiles( - "#include - int main() { volatile int v=0; return OSAtomicAdd32(1,&v); }" - HAVE_MAC_OS_X_ATOMIC) check_cxx_source_compiles( "#include @@ -339,7 +303,6 @@ endif(USE_EXTERNAL_BOOST) set(CPPCMS_PUBLIC_HEADERS application.h applications_pool.h - atomic_counter.h base64.h base_content.h base_view.h @@ -400,7 +363,6 @@ set(CPPCMS_SOURCES base_view.cpp views_pool.cpp internal_file_server.cpp - atomic_counter.cpp json.cpp encoding.cpp form.cpp @@ -631,7 +593,6 @@ add_executable(cppcms_config_find_param cppcms_config_find_param.cpp json.cpp) set(ALL_TESTS form_test proto_test - atomic_test encryptor_test storage_test cache_backend_test @@ -706,7 +667,6 @@ install(PROGRAMS cppcms_tmpl_cc cppcms_run set(CNF "${CMAKE_CURRENT_SOURCE_DIR}/tests") -add_test(atomic_test atomic_test) add_test(base64_test base64_test) add_test(encryptor_test encryptor_test) add_test(storage_test storage_test) diff --git a/application.cpp b/application.cpp index 899a26d..896579d 100644 --- a/application.cpp +++ b/application.cpp @@ -23,7 +23,6 @@ #include "service.h" #include "cppcms_error.h" #include "url_dispatcher.h" -#include "intrusive_ptr.h" #include "applications_pool.h" #include "http_response.h" #include "views_pool.h" @@ -49,7 +48,7 @@ struct application::data { { } cppcms::service *service; - intrusive_ptr conn; + booster::intrusive_ptr conn; int pool_id; url_dispatcher url; std::vector managed_children; @@ -94,7 +93,7 @@ url_dispatcher &application::dispatcher() return d->url; } -intrusive_ptr application::get_context() +booster::intrusive_ptr application::get_context() { return root()->d->conn; } @@ -106,9 +105,9 @@ http::context &application::context() return *root()->d->conn; } -intrusive_ptr application::release_context() +booster::intrusive_ptr application::release_context() { - intrusive_ptr ptr=root()->d->conn; + booster::intrusive_ptr ptr=root()->d->conn; assign_context(0); return ptr; } @@ -119,7 +118,7 @@ bool application::is_asynchronous() return pool_id() < 0; } -void application::assign_context(intrusive_ptr conn) +void application::assign_context(booster::intrusive_ptr conn) { root()->d->conn=conn; } @@ -220,43 +219,46 @@ void application::recycle() assign_context(0); } -void intrusive_ptr_add_ref(application *app) -{ - ++(app->root()->refs_); -} -// REMEMBER THIS IS CALLED FROM DESTRUCTOR!!! -void intrusive_ptr_release(application *app) -{ - // it is called in destructors... So be very careful - try { - app = app->root(); - long refs=--(app->refs_); - if(refs > 0) - return; - - cppcms::service &service=app->service(); - try { - app->recycle(); - } - catch(...) { - if(app->pool_id() < 0) { - service.applications_pool().put(app); - } - else - delete app; - throw; - } +} // cppcms - service.applications_pool().put(app); - // return the application to pool... or delete it if "pooled" - } - catch(...) +namespace booster { + void intrusive_ptr_add_ref(cppcms::application *app) { - // FIXME LOG IT? + ++(app->root()->refs_); } -} + // REMEMBER THIS IS CALLED FROM DESTRUCTOR!!! + void intrusive_ptr_release(cppcms::application *app) + { + // it is called in destructors... So be very careful + try { + app = app->root(); + long refs=--(app->refs_); + if(refs > 0) + return; + + cppcms::service &service=app->service(); + + try { + app->recycle(); + } + catch(...) { + if(app->pool_id() < 0) { + service.applications_pool().put(app); + } + else + delete app; + throw; + } -} // cppcms + service.applications_pool().put(app); + // return the application to pool... or delete it if "pooled" + } + catch(...) + { + // FIXME LOG IT? + } + } +} // booster diff --git a/application.h b/application.h index 298858a..207d7e4 100644 --- a/application.h +++ b/application.h @@ -21,12 +21,22 @@ #include "defs.h" #include -#include "atomic_counter.h" #include -#include "intrusive_ptr.h" +#include +#include #include namespace cppcms { + class application; +} + +namespace booster { + void CPPCMS_API intrusive_ptr_add_ref(cppcms::application *p); + void CPPCMS_API intrusive_ptr_release(cppcms::application *p); +} + + +namespace cppcms { class service; class url_dispatcher; @@ -45,15 +55,6 @@ namespace cppcms { class value; } - /// - /// Increase reference count of the p->root(). - /// - void CPPCMS_API intrusive_ptr_add_ref(application *p); - /// - /// Decrease reference count of the p->root(). If reference count is 0, and application is asynchronous: - /// destroy it, otherwise recycle it to the application pool for future use. - /// - void CPPCMS_API intrusive_ptr_release(application *p); /// /// \brief application class is the base class for all user created applications. @@ -230,19 +231,19 @@ namespace cppcms { /// /// Note: because application hierarchy shared same context, it affects all classes in it. /// - intrusive_ptr release_context(); + booster::intrusive_ptr release_context(); /// /// Get reference counted pointer to the http::context /// - intrusive_ptr get_context(); + booster::intrusive_ptr get_context(); /// /// Set context to the application. The application gets shared ownership on the context. /// /// Note: because application hierarchy shared same context, it affects all classes in it. /// - void assign_context(intrusive_ptr conn); + void assign_context(booster::intrusive_ptr conn); /// /// Returns true if current application was created as asynchronous application. @@ -276,10 +277,10 @@ namespace cppcms { application *parent_; application *root_; - atomic_counter refs_; + booster::atomic_counter refs_; friend class applications_pool; - friend void intrusive_ptr_add_ref(application *p); - friend void intrusive_ptr_release(application *p); + friend void booster::intrusive_ptr_add_ref(application *p); + friend void booster::intrusive_ptr_release(application *p); }; } // cppcms diff --git a/applications_pool.cpp b/applications_pool.cpp index b4cb7b7..b8ed161 100644 --- a/applications_pool.cpp +++ b/applications_pool.cpp @@ -26,13 +26,7 @@ #include #include "config.h" #include -#ifdef CPPCMS_USE_EXTERNAL_BOOST -# include -#else // Internal Boost -# include - namespace boost = cppcms_boost; -#endif - +#include #include namespace cppcms { @@ -109,8 +103,8 @@ namespace cppcms { }; struct applications_pool::data { - std::vector > apps; - typedef std::map > long_running_aps_type; + std::vector > apps; + typedef std::map > long_running_aps_type; long_running_aps_type long_running_aps; int limit; booster::recursive_mutex mutex; @@ -136,47 +130,47 @@ std::string applications_pool::script_name() void applications_pool::mount(std::auto_ptr aps) { lock_it lock(d->mutex); - d->apps.push_back(boost::shared_ptr(new app_data(script_name(),aps))); + d->apps.push_back(booster::shared_ptr(new app_data(script_name(),aps))); } void applications_pool::mount(std::auto_ptr aps,std::string path_info,int select) { lock_it lock(d->mutex); - d->apps.push_back(boost::shared_ptr(new app_data(script_name(),path_info,select,aps))); + d->apps.push_back(booster::shared_ptr(new app_data(script_name(),path_info,select,aps))); } void applications_pool::mount(std::auto_ptr aps,std::string script_name) { lock_it lock(d->mutex); - d->apps.push_back(boost::shared_ptr(new app_data(script_name,aps))); + d->apps.push_back(booster::shared_ptr(new app_data(script_name,aps))); } void applications_pool::mount(std::auto_ptr aps,std::string script_name,std::string path_info,int select) { lock_it lock(d->mutex); - d->apps.push_back(boost::shared_ptr(new app_data(script_name,path_info,select,aps))); + d->apps.push_back(booster::shared_ptr(new app_data(script_name,path_info,select,aps))); } -void applications_pool::mount(intrusive_ptr app) +void applications_pool::mount(booster::intrusive_ptr app) { lock_it lock(d->mutex); d->long_running_aps[app.get()]= - boost::shared_ptr(new long_running_app_data(script_name())); + booster::shared_ptr(new long_running_app_data(script_name())); } -void applications_pool::mount(intrusive_ptr app,std::string path_info,int select) +void applications_pool::mount(booster::intrusive_ptr app,std::string path_info,int select) { lock_it lock(d->mutex); d->long_running_aps[app.get()]= - boost::shared_ptr(new long_running_app_data(script_name(),path_info,select)); + booster::shared_ptr(new long_running_app_data(script_name(),path_info,select)); } -void applications_pool::mount(intrusive_ptr app,std::string script_name) +void applications_pool::mount(booster::intrusive_ptr app,std::string script_name) { lock_it lock(d->mutex); d->long_running_aps[app.get()]= - boost::shared_ptr(new long_running_app_data(script_name)); + booster::shared_ptr(new long_running_app_data(script_name)); } -void applications_pool::mount(intrusive_ptr app,std::string script_name,std::string path_info,int select) +void applications_pool::mount(booster::intrusive_ptr app,std::string script_name,std::string path_info,int select) { lock_it lock(d->mutex); d->long_running_aps[app.get()]= - boost::shared_ptr(new long_running_app_data(script_name,path_info,select)); + booster::shared_ptr(new long_running_app_data(script_name,path_info,select)); } bool applications_pool::matched(basic_app_data &data,std::string script_name,std::string path_info,std::string &matched) @@ -215,7 +209,7 @@ bool applications_pool::matched(basic_app_data &data,std::string script_name,std } -intrusive_ptr applications_pool::get(std::string script_name,std::string path_info,std::string &m) +booster::intrusive_ptr applications_pool::get(std::string script_name,std::string path_info,std::string &m) { lock_it lock(d->mutex); for(unsigned i=0;iapps.size();i++) { @@ -223,19 +217,19 @@ intrusive_ptr applications_pool::get(std::string script_name,std::s continue; if(d->apps[i]->pool.empty()) { - intrusive_ptr app=(*d->apps[i]->factory)(*srv_).release(); + booster::intrusive_ptr app=(*d->apps[i]->factory)(*srv_).release(); app->pool_id(i); return app; } d->apps[i]->size--; - intrusive_ptr app(*(d->apps[i]->pool.begin())); + booster::intrusive_ptr app(*(d->apps[i]->pool.begin())); d->apps[i]->pool.erase(app.get()); return app; } for(data::long_running_aps_type::iterator p=d->long_running_aps.begin();p!=d->long_running_aps.end();++p){ if(!matched(*p->second,script_name,path_info,m)) continue; - intrusive_ptr app=p->first; + booster::intrusive_ptr app=p->first; return app; } return 0; diff --git a/applications_pool.h b/applications_pool.h index 763a72e..f071d23 100644 --- a/applications_pool.h +++ b/applications_pool.h @@ -22,7 +22,7 @@ #include "defs.h" #include #include -#include "intrusive_ptr.h" +#include #include #include @@ -101,7 +101,7 @@ namespace cppcms { /// /// This member function is thread safe. /// - void mount(intrusive_ptr app); + void mount(booster::intrusive_ptr app); /// /// Mount an asynchronous application \a app for processing of requests for which CGI PATH_INFO /// matches the regular expression \a path_info. The marched part of an regular expression \a select would @@ -109,7 +109,7 @@ namespace cppcms { /// /// This member function is thread safe. /// - void mount(intrusive_ptr app,std::string path_info,int select); + void mount(booster::intrusive_ptr app,std::string path_info,int select); /// /// Mount an asynchronous application \a app for processing of requests for which CGI SCRIPT_NAME exactly /// matches \a script_name parameter. And PATH_INFO patches regular expression \a path_info. @@ -117,7 +117,7 @@ namespace cppcms { /// /// This member function is thread safe. /// - void mount(intrusive_ptr app,std::string script_name); + void mount(booster::intrusive_ptr app,std::string script_name); /// /// Mount an asynchronous application \a app for processing of requests for which CGI SCRIPT_NAME exactly /// matches \a script_name parameter. And PATH_INFO patches regular expression \a path_info. @@ -125,12 +125,12 @@ namespace cppcms { /// /// This member function is thread safe. /// - void mount(intrusive_ptr app,std::string script_name,std::string path_info, int select); + void mount(booster::intrusive_ptr app,std::string script_name,std::string path_info, int select); /// /// Internal API - do not use it directly /// - intrusive_ptr get(std::string script_name,std::string path_info,std::string &match); + booster::intrusive_ptr get(std::string script_name,std::string path_info,std::string &match); /// /// Internal API - do not use it directly /// diff --git a/atomic_counter.cpp b/atomic_counter.cpp deleted file mode 100644 index b0438bf..0000000 --- a/atomic_counter.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2008-2010 Artyom Beilis (Tonkikh) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// -/////////////////////////////////////////////////////////////////////////////// -#define CPPCMS_SOURCE -#include "atomic_counter.h" -#include "config.h" -#include - -#if defined(HAVE_WIN32_INTERLOCKED) - -# include -# define cppcms_atomic_set(p,v) ((p)->l=v) - long static cppcms_atomic_add_and_fetch_impl(volatile long *v,long d) - { - long old,prev; - do{ - old = *v; - prev = InterlockedCompareExchange(v,old+d,old); - } - while(prev != old); - return old+d; - } -# define cppcms_atomic_add_and_fetch(p,d) cppcms_atomic_add_and_fetch_impl(&(p)->l,d) - - -#elif defined(HAVE_FREEBSD_ATOMIC) - -# include -# include -# define cppcms_atomic_set(p,v) ((p)->ui=v) -# define cppcms_atomic_add_and_fetch(p,d) (atomic_fetchadd_int(&(p)->ui,d) + d) - - -#elif defined(HAVE_SOLARIS_ATOMIC) - -# include -# define cppcms_atomic_set(p,v) ((p)->ui=v) -# define cppcms_atomic_add_and_fetch(p,d) (atomic_add_int_nv(&(p)->ui,d)) - - -#elif defined(HAVE_MAC_OS_X_ATOMIC) - -# include -# define cppcms_atomic_set(p,v) ((p)->i=v) -# define cppcms_atomic_add_and_fetch(p,d) (OSAtomicAdd32(d,&(p)->i)) - -#elif defined HAVE_SYNC_FETCH_AND_ADD - -# define cppcms_atomic_set(p,v) ((p)->l=v) -# define cppcms_atomic_add_and_fetch(p,d) ( __sync_add_and_fetch(&(p)->i,d) ) - - -# elif defined(HAVE_GCC_BITS_EXCHANGE_AND_ADD) - -# include - using __gnu_cxx::__exchange_and_add; -# define cppcms_atomic_set(p,v) ((p)->i=v) -# define cppcms_atomic_add_and_fetch(p,d) ( __exchange_and_add(&(p)->i,d)+d ) - - -#elif defined(HAVE_GCC_EXT_EXCHANGE_AND_ADD) - -# include - using __gnu_cxx::__exchange_and_add; -# define cppcms_atomic_set(p,v) ((p)->i=v) -# define cppcms_atomic_add_and_fetch(p,d) ( __exchange_and_add(&(p)->i,d)+d ) - - -#else // Failing back to pthreads -# include -# define CPPCMS_PTHREAD_ATOMIC -#endif - - -namespace cppcms { - -#if !defined(CPPCMS_PTHREAD_ATOMIC) - atomic_counter::atomic_counter(long value) - { - memset(&value_,0,sizeof(value_)); - mutex_ = 0; - cppcms_atomic_set(&value_,value); - } - - atomic_counter::~atomic_counter() - { - } - - long atomic_counter::inc() - { - return cppcms_atomic_add_and_fetch( &value_, 1 ); - } - - long atomic_counter::dec() - { - return cppcms_atomic_add_and_fetch( &value_, -1 ); - } - - long atomic_counter::get() const - { - return cppcms_atomic_add_and_fetch( &value_, 0 ); - } - -#else - - #define MUTEX (reinterpret_cast(mutex_)) - atomic_counter::atomic_counter(long value) - { - mutex_ = new pthread_mutex_t; - pthread_mutex_init(MUTEX,0); - value_.l=value; - } - - atomic_counter::~atomic_counter() - { - pthread_mutex_destroy(MUTEX); - delete MUTEX; - mutex_ = 0; - } - - long atomic_counter::inc() - { - pthread_mutex_lock(MUTEX); - long result= ++value_.l; - pthread_mutex_unlock(MUTEX); - return result; - } - - long atomic_counter::dec() - { - pthread_mutex_lock(MUTEX); - long result= --value_.l; - pthread_mutex_unlock(MUTEX); - return result; - } - - long atomic_counter::get() const - { - pthread_mutex_lock(MUTEX); - long result= value_.l; - pthread_mutex_unlock(MUTEX); - return result; - } - - -#endif - - -} // cppcms - - - diff --git a/atomic_counter.h b/atomic_counter.h deleted file mode 100644 index f5751c3..0000000 --- a/atomic_counter.h +++ /dev/null @@ -1,94 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2008-2010 Artyom Beilis (Tonkikh) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// -/////////////////////////////////////////////////////////////////////////////// -#ifndef CPPCMS_ATOMIC_COUNT_H -#define CPPCMS_ATOMIC_COUNT_H - -#include "defs.h" - -namespace cppcms { - - /// - /// \brief Atomic counter is a class that allows perform counting in thread safe way. - /// - /// It is mainly used for reference counting. Under Windows it uses Interlocked API, under - /// other platforms it used built-in atomic operations or fails back to pthreads locking implementation. - /// - /// Notes: - /// - /// - This counter is not safe for use in process shared memory, when pthreads fall-back is used - /// - Under POSIX platform pthread_mutex_t is always present in order to make sure that we can implement - /// or remove pthread fall-back at any point not affecting ABI - /// - - class CPPCMS_API atomic_counter { - public: - /// - /// Create a counter with initial value v - /// - explicit atomic_counter( long v ); - ~atomic_counter(); - - /// - /// Increment and return the result after increment atomically - /// - long operator++() - { - return inc(); - } - /// - /// Decrement and return the result after decrement atomically - /// - long operator--() - { - return dec(); - } - /// - /// Return current value - atomically - /// - operator long() const - { - return get(); - } - private: - long inc(); - long dec(); - long get() const; - - atomic_counter(atomic_counter const &); - atomic_counter & operator=(atomic_counter const &); - - mutable union { - int i; - unsigned ui; - long l; - unsigned long ul; - long long ll; - unsigned long long ull; - } value_; - // Is actually used for platforms without lock - // it would not be used when atomic operations - // available - void *mutex_; - }; - -} // cppcms - -#endif - - diff --git a/base_cache.h b/base_cache.h index b76f59b..5f3f8b9 100644 --- a/base_cache.h +++ b/base_cache.h @@ -22,7 +22,7 @@ #include #include #include "defs.h" -#include "intrusive_ptr.h" +#include #include "cstdint.h" namespace cppcms { @@ -46,15 +46,18 @@ namespace cppcms { } }; } // impl +} //cppcms +namespace booster { - inline void intrusive_ptr_add_ref(impl::base_cache *ptr) + inline void intrusive_ptr_add_ref(cppcms::impl::base_cache *ptr) { ptr->add_ref(); } - inline void intrusive_ptr_release(impl::base_cache *ptr) + inline void intrusive_ptr_release(cppcms::impl::base_cache *ptr) { if(ptr && ptr->del_ref()) delete ptr; } -} // cppcms +} // booster + #endif diff --git a/cache_interface.h b/cache_interface.h index 48f90cc..d444979 100644 --- a/cache_interface.h +++ b/cache_interface.h @@ -24,7 +24,7 @@ #include "defs.h" #include -#include "intrusive_ptr.h" +#include #include #include "cstdint.h" @@ -269,7 +269,7 @@ namespace cppcms { booster::hold_ptr d; http::context *context_; std::set triggers_; - intrusive_ptr cache_module_; + booster::intrusive_ptr cache_module_; uint32_t page_compression_used_ : 1; uint32_t reserved : 31; diff --git a/cache_over_ip.cpp b/cache_over_ip.cpp index 78ec485..84cf5e7 100644 --- a/cache_over_ip.cpp +++ b/cache_over_ip.cpp @@ -18,7 +18,7 @@ /////////////////////////////////////////////////////////////////////////////// #define CPPCMS_SOURCE #include "tcp_cache_client.h" -#include "atomic_counter.h" +#include #include @@ -26,7 +26,7 @@ namespace cppcms { namespace impl { class cache_over_ip : public base_cache { public: - cache_over_ip(std::vector ips,std::vector ports,intrusive_ptr l1) : + cache_over_ip(std::vector ips,std::vector ports,booster::intrusive_ptr l1) : ips_(ips), ports_(ports), l1_(l1), @@ -126,15 +126,15 @@ namespace impl { booster::thread_specific_ptr tcp_; std::vector ips_; std::vector ports_; - intrusive_ptr l1_; - atomic_counter refs_; + booster::intrusive_ptr l1_; + booster::atomic_counter refs_; }; -intrusive_ptr CPPCMS_API +booster::intrusive_ptr CPPCMS_API tcp_cache_factory( std::vector const &ips, std::vector const &ports, - intrusive_ptr l1) + booster::intrusive_ptr l1) { return new cache_over_ip(ips,ports,l1); } diff --git a/cache_over_ip.h b/cache_over_ip.h index 4b374a8..1a75b5f 100644 --- a/cache_over_ip.h +++ b/cache_over_ip.h @@ -19,17 +19,17 @@ #ifndef CPPCMS_CACHE_OVER_IP_H #define CPPCMS_CACHE_OVER_IP_H #include "defs.h" -#include "intrusive_ptr.h" +#include #include "base_cache.h" #include #include namespace cppcms { namespace impl { - intrusive_ptr CPPCMS_API + booster::intrusive_ptr CPPCMS_API tcp_cache_factory( std::vector const &ips, std::vector const &ports, - intrusive_ptr l1); + booster::intrusive_ptr l1); } } diff --git a/cache_pool.cpp b/cache_pool.cpp index 135db96..e328dd5 100644 --- a/cache_pool.cpp +++ b/cache_pool.cpp @@ -27,7 +27,7 @@ namespace cppcms { struct cache_pool::data { - intrusive_ptr module; + booster::intrusive_ptr module; }; cache_pool::cache_pool(json::value const &settings) : @@ -65,7 +65,7 @@ cache_pool::cache_pool(json::value const &settings) : throw cppcms_error("Invalid settings in cache.tcp.ports or cache.tcp.ips"); } - intrusive_ptr l1=d->module; + booster::intrusive_ptr l1=d->module; d->module=impl::tcp_cache_factory(ips,ports,l1); } } @@ -74,7 +74,7 @@ cache_pool::~cache_pool() { } -intrusive_ptr cache_pool::get() +booster::intrusive_ptr cache_pool::get() { return d->module; } diff --git a/cache_pool.h b/cache_pool.h index dd310a9..6e8a085 100644 --- a/cache_pool.h +++ b/cache_pool.h @@ -21,7 +21,7 @@ #include "defs.h" #include -#include "intrusive_ptr.h" +#include #include namespace cppcms { @@ -32,7 +32,7 @@ namespace cppcms { public: cache_pool(json::value const &settings); ~cache_pool(); - intrusive_ptr get(); + booster::intrusive_ptr get(); private: struct data; booster::hold_ptr d; diff --git a/cache_server_main.cpp b/cache_server_main.cpp index 9608b53..24e4b62 100644 --- a/cache_server_main.cpp +++ b/cache_server_main.cpp @@ -149,7 +149,7 @@ int main(int argc,char **argv) { params par(argc,argv); - cppcms::intrusive_ptr cache; + booster::intrusive_ptr cache; //auto_ptr storage; if(par.en_cache) diff --git a/cache_storage.cpp b/cache_storage.cpp index 77e5877..03ca924 100644 --- a/cache_storage.cpp +++ b/cache_storage.cpp @@ -398,13 +398,13 @@ public: }; // mem cache -intrusive_ptr thread_cache_factory(unsigned items) +booster::intrusive_ptr thread_cache_factory(unsigned items) { return new mem_cache(items); } #ifndef CPPCMS_WIN32 -intrusive_ptr process_cache_factory(size_t memory) +booster::intrusive_ptr process_cache_factory(size_t memory) { process_settings::init(memory); return new mem_cache(0); diff --git a/cache_storage.h b/cache_storage.h index 65c39f1..1ce4805 100644 --- a/cache_storage.h +++ b/cache_storage.h @@ -19,14 +19,14 @@ #ifndef THREAD_CHACHE_H #define THREAD_CHACHE_H #include "base_cache.h" -#include "intrusive_ptr.h" +#include #include "defs.h" namespace cppcms { namespace impl { - intrusive_ptr CPPCMS_API thread_cache_factory(unsigned items); + booster::intrusive_ptr CPPCMS_API thread_cache_factory(unsigned items); #ifndef CPPCMS_WIN32 - intrusive_ptr CPPCMS_API process_cache_factory(size_t memory); + booster::intrusive_ptr CPPCMS_API process_cache_factory(size_t memory); #endif } // impl } // cppcms diff --git a/cgi_acceptor.h b/cgi_acceptor.h index 7c9a2ed..919c445 100644 --- a/cgi_acceptor.h +++ b/cgi_acceptor.h @@ -107,7 +107,7 @@ namespace impl { if(!e) { if(tcp_) asio_socket_->set_option(io::socket::tcp_no_delay,true); - intrusive_ptr< ::cppcms::http::context> cnt(new ::cppcms::http::context(api_)); + booster::intrusive_ptr< ::cppcms::http::context> cnt(new ::cppcms::http::context(api_)); api_=0; cnt->run(); } @@ -115,7 +115,7 @@ namespace impl { } cppcms::service &srv_; - intrusive_ptr api_; + booster::intrusive_ptr api_; booster::aio::socket *asio_socket_,acceptor_; bool stopped_; bool tcp_; diff --git a/cgi_api.cpp b/cgi_api.cpp index 12c29c7..df2c885 100644 --- a/cgi_api.cpp +++ b/cgi_api.cpp @@ -138,7 +138,7 @@ public: struct none{}; struct eof{}; typedef std::pair pair_type; - typedef boost::shared_ptr file_type; + typedef booster::shared_ptr file_type; typedef enum { none, eof, error } result_type; typedef boost::variant variant_type; @@ -250,7 +250,7 @@ cppcms::service &connection::service() { return *service_; } -intrusive_ptr connection::self() +booster::intrusive_ptr connection::self() { return this; } diff --git a/cgi_api.h b/cgi_api.h index 2b62681..9fa33b8 100644 --- a/cgi_api.h +++ b/cgi_api.h @@ -20,8 +20,8 @@ #define CPPCMS_IMPL_CGI_API_H #include -#include "refcounted.h" -#include "intrusive_ptr.h" +#include +#include #include #include #include @@ -55,7 +55,7 @@ namespace cgi { virtual ~acceptor(){} }; - class connection : public refcounted + class connection : public booster::refcounted { public: connection(cppcms::service &srv); @@ -103,7 +103,7 @@ namespace cgi { /****************************************************************************/ protected: - intrusive_ptr self(); + booster::intrusive_ptr self(); void async_read(void *,size_t,io_handler const &h); void async_write(void const *,size_t,io_handler const &h); private: diff --git a/connection_forwarder.cpp b/connection_forwarder.cpp index 9bd8b40..1529f31 100644 --- a/connection_forwarder.cpp +++ b/connection_forwarder.cpp @@ -30,16 +30,17 @@ #include #include +#include +#include + #ifdef CPPCMS_USE_EXTERNAL_BOOST # include -# include # include # if defined(CPPCMS_WIN32) && _WIN32_WINNT <= 0x0501 && !defined(BOOST_ASIO_DISABLE_IOCP) # define NO_CANCELIO # endif #else // Internal Boost # include -# include # include namespace boost = cppcms_boost; # if defined(CPPCMS_WIN32) && _WIN32_WINNT <= 0x0501 && !defined(CPPCMS_BOOST_ASIO_DISABLE_IOCP) @@ -51,9 +52,9 @@ namespace io = booster::aio; namespace cppcms { namespace impl { - class tcp_pipe : public boost::enable_shared_from_this { + class tcp_pipe : public booster::enable_shared_from_this { public: - tcp_pipe(intrusive_ptr connection,std::string const &ip,int port) : + tcp_pipe(booster::intrusive_ptr connection,std::string const &ip,int port) : connection_(connection), ip_(ip), port_(port), @@ -128,7 +129,7 @@ namespace cppcms { } } - intrusive_ptr connection_; + booster::intrusive_ptr connection_; std::string ip_; int port_; std::string data_; @@ -150,7 +151,7 @@ namespace cppcms { } void connection_forwarder::main(std::string unused) { - intrusive_ptr con = release_context(); + booster::intrusive_ptr con = release_context(); std::string env_str; env_str.reserve(1000); @@ -180,7 +181,7 @@ namespace cppcms { header+=','; header.append(reinterpret_cast(post.first),post.second); - boost::shared_ptr pipe(new impl::tcp_pipe(con,ip_,port_)); + booster::shared_ptr pipe(new impl::tcp_pipe(con,ip_,port_)); pipe->async_send_receive(header); } }; diff --git a/fastcgi_api.cpp b/fastcgi_api.cpp index 37d7882..41eaebd 100644 --- a/fastcgi_api.cpp +++ b/fastcgi_api.cpp @@ -639,7 +639,7 @@ namespace cgi { } - intrusive_ptr self() + booster::intrusive_ptr self() { return this; } diff --git a/hello_world.cpp b/hello_world.cpp index 88e2cb3..ddf46cb 100644 --- a/hello_world.cpp +++ b/hello_world.cpp @@ -26,7 +26,7 @@ #include "localization.h" #include "http_context.h" #include "filters.h" -#include "intrusive_ptr.h" +#include #include "form.h" #include "cache_interface.h" #include "session_interface.h" @@ -79,12 +79,12 @@ public: release_context()->async_complete_response(); } else if(pos == messages_.size()) { - cppcms::intrusive_ptr context=release_context(); + booster::intrusive_ptr context=release_context(); waiters_.insert(context); context->async_on_peer_reset( boost::bind( &chat::remove_context, - cppcms::intrusive_ptr(this), + booster::intrusive_ptr(this), context)); } else { @@ -92,7 +92,7 @@ public: release_context()->async_complete_response(); } } - void remove_context(cppcms::intrusive_ptr context) + void remove_context(booster::intrusive_ptr context) { std::cerr<<"Connection closed"< messages_; - typedef std::set > waiters_type; + typedef std::set > waiters_type; waiters_type waiters_; }; @@ -136,7 +136,7 @@ private: { broadcast(); timer_.expires_from_now(booster::ptime(100)); - timer_.async_wait(cppcms::util::mem_bind(&stock::on_timeout,cppcms::intrusive_ptr(this))); + timer_.async_wait(cppcms::util::mem_bind(&stock::on_timeout,booster::intrusive_ptr(this))); } void get() { @@ -186,7 +186,7 @@ private: int counter_; double price_; - std::vector > all_; + std::vector > all_; booster::aio::deadline_timer timer_; }; @@ -454,7 +454,7 @@ int main(int argc,char **argv) { try { cppcms::service service(argc,argv); - cppcms::intrusive_ptr c=new chat(service); + booster::intrusive_ptr c=new chat(service); service.applications_pool().mount(c,"/chat"); service.applications_pool().mount(cppcms::applications_factory(),"/hello"); service.applications_pool().mount(new stock(service),"/stock"); diff --git a/http_api.cpp b/http_api.cpp index 23f1cfd..14da663 100644 --- a/http_api.cpp +++ b/http_api.cpp @@ -80,13 +80,13 @@ namespace cgi { { self_->some_headers_data_read(e,n,h_); } - binder(intrusive_ptr self,handler const &h) : + binder(booster::intrusive_ptr self,handler const &h) : self_(self), h_(h) { } private: - intrusive_ptr self_; + booster::intrusive_ptr self_; handler h_; }; virtual void async_read_headers(handler const &h) @@ -414,7 +414,7 @@ namespace cgi { } - intrusive_ptr self() + booster::intrusive_ptr self() { return this; } diff --git a/http_context.cpp b/http_context.cpp index 3dc9bf0..1ee3c9c 100644 --- a/http_context.cpp +++ b/http_context.cpp @@ -56,7 +56,7 @@ namespace http { } }; -context::context(intrusive_ptr conn) : +context::context(booster::intrusive_ptr conn) : conn_(conn) { d.reset(new data(*this)); @@ -95,7 +95,7 @@ void context::on_request_ready(bool error) std::string script_name = conn_->getenv("SCRIPT_NAME"); std::string matched; - intrusive_ptr app = service().applications_pool().get(script_name,path_info,matched); + booster::intrusive_ptr app = service().applications_pool().get(script_name,path_info,matched); if(!app) { response().io_mode(http::response::asynchronous); @@ -115,7 +115,7 @@ void context::on_request_ready(bool error) } } // static -void context::dispatch(intrusive_ptr app,std::string url,bool syncronous) +void context::dispatch(booster::intrusive_ptr app,std::string url,bool syncronous) { try { if(syncronous) @@ -169,15 +169,15 @@ void context::try_restart(bool e) if(e) return; if(conn_->is_reuseable()) { - intrusive_ptr cont=new context(conn_); + booster::intrusive_ptr cont=new context(conn_); cont->run(); } conn_=0; } -intrusive_ptr context::self() +booster::intrusive_ptr context::self() { - intrusive_ptr ptr(this); + booster::intrusive_ptr ptr(this); return ptr; } diff --git a/http_context.h b/http_context.h index c5a9b7f..7a331c4 100644 --- a/http_context.h +++ b/http_context.h @@ -21,8 +21,8 @@ #include "defs.h" #include -#include "intrusive_ptr.h" -#include "refcounted.h" +#include +#include #include #include @@ -48,13 +48,13 @@ namespace cppcms { /// and destroyed when HTTP request/response is completed /// - class CPPCMS_API context : public refcounted + class CPPCMS_API context : public booster::refcounted { public: /// /// Internal API, don't use it /// - context(intrusive_ptr conn); + context(booster::intrusive_ptr conn); /// /// Destructor. ~context(); @@ -168,13 +168,13 @@ namespace cppcms { void async_on_peer_reset(booster::function const &h); private: void on_request_ready(bool error); - static void dispatch(intrusive_ptr app,std::string url,bool syncronous); + static void dispatch(booster::intrusive_ptr app,std::string url,bool syncronous); void try_restart(bool e); - intrusive_ptr self(); + booster::intrusive_ptr self(); struct data; booster::hold_ptr d; - intrusive_ptr conn_; + booster::intrusive_ptr conn_; }; } diff --git a/http_request.cpp b/http_request.cpp index 3c2268f..de58997 100644 --- a/http_request.cpp +++ b/http_request.cpp @@ -26,13 +26,8 @@ #include #include -#include "config.h" -#ifdef CPPCMS_USE_EXTERNAL_BOOST -# include -#else // Internal Boost -# include - namespace boost = cppcms_boost; -#endif +#include + namespace cppcms { namespace http { @@ -105,7 +100,7 @@ bool request::parse_cookies() struct request::data { - std::vector > files; + std::vector > files; std::vector post_data; }; diff --git a/intrusive_ptr.h b/intrusive_ptr.h deleted file mode 100644 index 11da2b1..0000000 --- a/intrusive_ptr.h +++ /dev/null @@ -1,218 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2008-2010 Artyom Beilis (Tonkikh) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// -/////////////////////////////////////////////////////////////////////////////// -#ifndef CPPCMS_INTRUSIVE_PTR_H_INCLUDED -#define CPPCMS_INTRUSIVE_PTR_H_INCLUDED - -// -// intrusive_ptr.hpp -// -// Copyright (c) 2001, 2002 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/libs/smart_ptr/intrusive_ptr.html for documentation. -// - - -#include // for std::less -#include // for std::basic_ostream - - -namespace cppcms -{ - -// -// intrusive_ptr -// -// A smart pointer that uses intrusive reference counting. -// -// Relies on unqualified calls to -// -// void intrusive_ptr_add_ref(T * p); -// void intrusive_ptr_release(T * p); -// -// (p != 0) -// -// The object is responsible for destroying itself. -// - -template class intrusive_ptr -{ -private: - - typedef intrusive_ptr this_type; - -public: - - typedef T element_type; - - intrusive_ptr(): p_(0) - { - } - - intrusive_ptr(T * p, bool add_ref = true): p_(p) - { - if(p_ != 0 && add_ref) intrusive_ptr_add_ref(p_); - } - - intrusive_ptr(intrusive_ptr const & rhs): p_(rhs.p_) - { - if(p_ != 0) intrusive_ptr_add_ref(p_); - } - - ~intrusive_ptr() - { - if(p_ != 0) intrusive_ptr_release(p_); - } - - template intrusive_ptr(intrusive_ptr const & rhs): p_(rhs.get()) - { - if(p_ != 0) intrusive_ptr_add_ref(p_); - } - - intrusive_ptr & operator=(intrusive_ptr const & rhs) - { - this_type(rhs).swap(*this); - return *this; - } - - intrusive_ptr & operator=(T * rhs) - { - this_type(rhs).swap(*this); - return *this; - } - - T * get() const - { - return p_; - } - - T & operator*() const - { - return *p_; - } - - T * operator->() const - { - return p_; - } - - - typedef T * this_type::*unspecified_bool_type; - - operator unspecified_bool_type () const - { - return p_ == 0? 0: &this_type::p_; - } - - // operator! is a Borland-specific workaround - bool operator! () const - { - return p_ == 0; - } - - void swap(intrusive_ptr & rhs) - { - T * tmp = p_; - p_ = rhs.p_; - rhs.p_ = tmp; - } - -private: - - T * p_; -}; - -template inline bool operator==(intrusive_ptr const & a, intrusive_ptr const & b) -{ - return a.get() == b.get(); -} - -template inline bool operator!=(intrusive_ptr const & a, intrusive_ptr const & b) -{ - return a.get() != b.get(); -} - -template inline bool operator==(intrusive_ptr const & a, T * b) -{ - return a.get() == b; -} - -template inline bool operator!=(intrusive_ptr const & a, T * b) -{ - return a.get() != b; -} - -template inline bool operator==(T * a, intrusive_ptr const & b) -{ - return a == b.get(); -} - -template inline bool operator!=(T * a, intrusive_ptr const & b) -{ - return a != b.get(); -} - -template inline bool operator<(intrusive_ptr const & a, intrusive_ptr const & b) -{ - return std::less()(a.get(), b.get()); -} - -template void swap(intrusive_ptr & lhs, intrusive_ptr & rhs) -{ - lhs.swap(rhs); -} - -// mem_fn support - -template T * get_pointer(intrusive_ptr const & p) -{ - return p.get(); -} - -template intrusive_ptr static_pointer_cast(intrusive_ptr const & p) -{ - return static_cast(p.get()); -} - -template intrusive_ptr const_pointer_cast(intrusive_ptr const & p) -{ - return const_cast(p.get()); -} - -template intrusive_ptr dynamic_pointer_cast(intrusive_ptr const & p) -{ - return dynamic_cast(p.get()); -} - -// operator<< - - -template std::basic_ostream & operator<< (std::basic_ostream & os, intrusive_ptr const & p) -{ - os << p.get(); - return os; -} - - -} // namespace cppcms - -#endif // #ifndef CPPCMS_INTRUSIVE_PTR_H_INCLUDED diff --git a/logger.cpp b/logger.cpp index b377450..4e59668 100644 --- a/logger.cpp +++ b/logger.cpp @@ -22,13 +22,12 @@ #include "config.h" #ifdef CPPCMS_USE_EXTERNAL_BOOST # include -# include #else // Internal Boost # include -# include namespace boost = cppcms_boost; #endif +#include #include #include @@ -87,7 +86,7 @@ namespace cppcms { typedef std::map module_level_type; module_level_type module_level; std::auto_ptr output; - std::vector > devices; + std::vector > devices; }; logger::level_type logger::module_level(char const *module) diff --git a/refcounted.h b/refcounted.h deleted file mode 100644 index 6702c87..0000000 --- a/refcounted.h +++ /dev/null @@ -1,63 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2008-2010 Artyom Beilis (Tonkikh) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . -// -/////////////////////////////////////////////////////////////////////////////// -#ifndef CPPCMS_REFCOUNTED_H -#define CPPCMS_REFCOUNTED_H - -#include "atomic_counter.h" - -namespace cppcms { - - class refcounted; - void intrusive_ptr_add_ref(refcounted *ptr); - void intrusive_ptr_release(refcounted *ptr); - - class refcounted { - public: - refcounted() : - refs_(0) - { - } - - virtual ~refcounted() - { - } - - private: - friend void intrusive_ptr_add_ref(refcounted *); - friend void intrusive_ptr_release(refcounted *); - - refcounted(refcounted const &other); - refcounted const &operator=(refcounted const &other); - atomic_counter refs_; - }; - - inline void intrusive_ptr_add_ref(refcounted *p) - { - ++p->refs_; - } - inline void intrusive_ptr_release(refcounted *p) - { - if(p && --p->refs_ == 0) - delete p; - } - -} - - -#endif diff --git a/rpc_json.cpp b/rpc_json.cpp index a78102e..12b7a14 100644 --- a/rpc_json.cpp +++ b/rpc_json.cpp @@ -117,7 +117,7 @@ namespace rpc { return params_; } - void json_call::attach_context(intrusive_ptr c) + void json_call::attach_context(booster::intrusive_ptr c) { context_ = c; } @@ -232,11 +232,11 @@ namespace rpc { check_call(); current_call_->return_error(context(),e); } - intrusive_ptr json_rpc_server::release_call() + booster::intrusive_ptr json_rpc_server::release_call() { check_call(); current_call_->attach_context(release_context()); - intrusive_ptr call = current_call_; + booster::intrusive_ptr call = current_call_; current_call_ = 0; return call; } diff --git a/rpc_json.h b/rpc_json.h index b4e8d68..a40740a 100644 --- a/rpc_json.h +++ b/rpc_json.h @@ -20,8 +20,8 @@ #define CPPCMS_RPC_JSON_OBJECT_H #include "application.h" -#include "refcounted.h" -#include "intrusive_ptr.h" +#include +#include #include #include "json.h" #include "cppcms_error.h" @@ -51,7 +51,7 @@ namespace rpc { /// for handling asynchronous responses only. Similar API is provided /// in json_rpc_server class for synchronous methods. /// - class CPPCMS_API json_call : public refcounted { + class CPPCMS_API json_call : public booster::refcounted { public: /// @@ -100,10 +100,10 @@ namespace rpc { friend class json_rpc_server; void return_result(http::context &,json::value const &); void return_error(http::context &,json::value const &); - void attach_context(intrusive_ptr context); + void attach_context(booster::intrusive_ptr context); void check_not_notification(); - intrusive_ptr context_; + booster::intrusive_ptr context_; json::value id_; json::array params_; std::string method_; @@ -160,7 +160,7 @@ namespace rpc { /// Release json_call for asynchronous responses. Calls release_context() and /// assignes it to json_call object. /// - intrusive_ptr release_call(); + booster::intrusive_ptr release_call(); json_rpc_server(cppcms::service &srv); ~json_rpc_server(); @@ -198,7 +198,7 @@ namespace rpc { }; typedef std::map methods_map_type; methods_map_type methods_; - intrusive_ptr current_call_; + booster::intrusive_ptr current_call_; std::string smd_; diff --git a/scgi_api.cpp b/scgi_api.cpp index b07e954..e7e7909 100644 --- a/scgi_api.cpp +++ b/scgi_api.cpp @@ -178,7 +178,7 @@ namespace cgi { private: size_t start_,end_,sep_; - intrusive_ptr self() + booster::intrusive_ptr self() { return this; } diff --git a/service.cpp b/service.cpp index dd709ac..4476a2e 100644 --- a/service.cpp +++ b/service.cpp @@ -546,7 +546,7 @@ void service::setup_acceptor(json::value const &v,int backlog) if(!a.get()) throw cppcms_error("Unknown api: " + api); - impl_->acceptors_.push_back(boost::shared_ptr(a)); + impl_->acceptors_.push_back(booster::shared_ptr(a)); } void service::start_acceptor() diff --git a/service_impl.h b/service_impl.h index 189461f..8bc22b3 100644 --- a/service_impl.h +++ b/service_impl.h @@ -22,16 +22,9 @@ #include "json.h" #include "localization.h" #include +#include #include -#include "config.h" -#ifdef CPPCMS_USE_EXTERNAL_BOOST -# include -#else // Internal Boost -# include - namespace boost = cppcms_boost; -#endif - namespace cppcms { class service; @@ -58,7 +51,7 @@ namespace impl { friend class cppcms::service; std::auto_ptr io_service_; - std::vector > acceptors_; + std::vector > acceptors_; std::auto_ptr settings_; std::auto_ptr applications_pool_; std::auto_ptr thread_pool_; diff --git a/session_api.h b/session_api.h index c67de42..297d5ea 100644 --- a/session_api.h +++ b/session_api.h @@ -21,8 +21,8 @@ #include "defs.h" #include -#include "refcounted.h" -#include "intrusive_ptr.h" +#include +#include #include namespace cppcms { @@ -31,7 +31,7 @@ class session_interface; class session_api : public booster::noncopyable, - public refcounted + public booster::refcounted { public: virtual void save(session_interface &,std::string const &data,time_t timeout, bool new_data, bool on_server) = 0; @@ -44,7 +44,7 @@ class session_api_factory { public: virtual bool requires_gc() = 0; virtual void gc() = 0; - virtual intrusive_ptr get() = 0; + virtual booster::intrusive_ptr get() = 0; virtual ~session_api_factory() {} }; diff --git a/session_dual.cpp b/session_dual.cpp index 47202e1..bf6b170 100644 --- a/session_dual.cpp +++ b/session_dual.cpp @@ -29,7 +29,7 @@ namespace sessions { struct session_dual::data {}; -session_dual::session_dual(std::auto_ptr enc,intrusive_ptr storage,size_t limit) : +session_dual::session_dual(std::auto_ptr enc,booster::intrusive_ptr storage,size_t limit) : client_(new session_cookies(enc)), server_(new session_sid(storage)), data_size_limit_(limit) diff --git a/session_dual.h b/session_dual.h index aeb5025..ff75a31 100644 --- a/session_dual.h +++ b/session_dual.h @@ -22,7 +22,7 @@ #include "session_api.h" #include "defs.h" #include -#include "intrusive_ptr.h" +#include #include namespace cppcms { @@ -36,7 +36,7 @@ class encryptor; class CPPCMS_API session_dual : public session_api { public: session_dual( std::auto_ptr enc, - intrusive_ptr storage, + booster::intrusive_ptr storage, size_t data_size_limit); virtual ~session_dual(); virtual void save(session_interface &,std::string const &data,time_t timeout,bool new_session,bool on_server); @@ -45,8 +45,8 @@ public: private: struct data; booster::hold_ptr d; - intrusive_ptr client_; - intrusive_ptr server_; + booster::intrusive_ptr client_; + booster::intrusive_ptr server_; size_t data_size_limit_; }; diff --git a/session_interface.h b/session_interface.h index 32cfcc6..68fb09b 100644 --- a/session_interface.h +++ b/session_interface.h @@ -22,7 +22,7 @@ #include "defs.h" #include #include -#include "intrusive_ptr.h" +#include #include "cstdint.h" #include #include @@ -137,7 +137,7 @@ private: // storage itself - intrusive_ptr storage_; + booster::intrusive_ptr storage_; struct data; booster::hold_ptr d; // for future use diff --git a/session_memory_storage.cpp b/session_memory_storage.cpp index 2d20175..4ef3625 100644 --- a/session_memory_storage.cpp +++ b/session_memory_storage.cpp @@ -113,7 +113,7 @@ session_memory_storage_factory::~session_memory_storage_factory() { } -intrusive_ptr session_memory_storage_factory::get() +booster::intrusive_ptr session_memory_storage_factory::get() { return storage_; } diff --git a/session_memory_storage.h b/session_memory_storage.h index 879d6f9..40a683c 100644 --- a/session_memory_storage.h +++ b/session_memory_storage.h @@ -27,12 +27,12 @@ namespace sessions { class CPPCMS_API session_memory_storage_factory : public session_storage_factory { public: session_memory_storage_factory(); - virtual intrusive_ptr get(); + virtual booster::intrusive_ptr get(); virtual bool requires_gc(); virtual void gc_job(); virtual ~session_memory_storage_factory(); private: - intrusive_ptr storage_; + booster::intrusive_ptr storage_; }; } // sessions diff --git a/session_pool.cpp b/session_pool.cpp index a2d02f5..236051a 100644 --- a/session_pool.cpp +++ b/session_pool.cpp @@ -26,16 +26,13 @@ #include "hmac_encryptor.h" #include "json.h" #include "cppcms_error.h" +#include +#include #include "config.h" - #ifdef CPPCMS_USE_EXTERNAL_BOOST # include -# include -# include #else // Internal Boost # include -# include -# include namespace boost = cppcms_boost; #endif @@ -87,7 +84,7 @@ struct session_pool::sid_factory : public session_api_factory if(pool_->storage_.get()) pool_->storage_->gc_job(); } - intrusive_ptr get() { + booster::intrusive_ptr get() { if(pool_->storage_.get()) return new session_sid(pool_->storage_->get()); else @@ -104,7 +101,7 @@ struct session_pool::cookies_factory : public session_api_factory return false; } void gc() {} - intrusive_ptr get() { + booster::intrusive_ptr get() { if(pool_->encryptor_.get()) return new session_cookies(pool_->encryptor_->get()); else @@ -128,7 +125,7 @@ struct session_pool::dual_factory : public session_api_factory if(pool_->storage_.get()) pool_->storage_->gc_job(); } - intrusive_ptr get() { + booster::intrusive_ptr get() { if(pool_->storage_.get() && pool_->encryptor_.get()) return new session_dual(pool_->encryptor_->get(),pool_->storage_->get(),limit_); else @@ -140,7 +137,7 @@ private: }; -class session_pool::gc_job : public boost::enable_shared_from_this { +class session_pool::gc_job : public booster::enable_shared_from_this { public: gc_job(service *ser,int freq,session_pool *pool) : timer_(new booster::aio::deadline_timer(ser->get_io_service())), @@ -160,7 +157,7 @@ private: timer_->expires_from_now(booster::ptime(freq_)); timer_->async_wait(boost::bind(&gc_job::async_run,shared_from_this())); } - boost::shared_ptr timer_; + booster::shared_ptr timer_; service *service_; int freq_; session_pool *pool_; @@ -249,7 +246,7 @@ void session_pool::after_fork() return; int frequency = service_->settings().get("session.gc",0); if(frequency > 0) { - boost::shared_ptr job(new gc_job(service_,frequency,this)); + booster::shared_ptr job(new gc_job(service_,frequency,this)); job->async_run(); } } @@ -259,7 +256,7 @@ session_pool::~session_pool() { } -intrusive_ptr session_pool::get() +booster::intrusive_ptr session_pool::get() { if(backend_.get()) return backend_->get(); diff --git a/session_pool.h b/session_pool.h index 408e9df..9637a8b 100644 --- a/session_pool.h +++ b/session_pool.h @@ -20,7 +20,7 @@ #define CPPCMS_SESSION_POOL_H #include "defs.h" -#include "intrusive_ptr.h" +#include #include #include "session_api.h" @@ -41,7 +41,7 @@ namespace cppcms { void init(); - intrusive_ptr get(); + booster::intrusive_ptr get(); void backend(std::auto_ptr b); void encryptor(std::auto_ptr e); diff --git a/session_posix_file_storage.cpp b/session_posix_file_storage.cpp index b03f58f..6f1fbd9 100644 --- a/session_posix_file_storage.cpp +++ b/session_posix_file_storage.cpp @@ -377,7 +377,7 @@ session_file_storage_factory::~session_file_storage_factory() { } -intrusive_ptr session_file_storage_factory::get() +booster::intrusive_ptr session_file_storage_factory::get() { return storage_; } diff --git a/session_posix_file_storage.h b/session_posix_file_storage.h index 639b7a8..127c59b 100644 --- a/session_posix_file_storage.h +++ b/session_posix_file_storage.h @@ -71,13 +71,13 @@ namespace sessions { class CPPCMS_API session_file_storage_factory : public session_storage_factory { public: session_file_storage_factory(std::string path,int conc,int proc_no,bool force_lock); - virtual intrusive_ptr get(); + virtual booster::intrusive_ptr get(); virtual bool requires_gc(); virtual void gc_job(); virtual ~session_file_storage_factory(); private: struct data; - intrusive_ptr storage_; + booster::intrusive_ptr storage_; }; } // sessions } // cppcms diff --git a/session_sid.cpp b/session_sid.cpp index 82f4a28..7c618a6 100644 --- a/session_sid.cpp +++ b/session_sid.cpp @@ -111,7 +111,7 @@ namespace impl { struct session_sid::data {}; -session_sid::session_sid(intrusive_ptr st) : +session_sid::session_sid(booster::intrusive_ptr st) : storage_(st) { } diff --git a/session_sid.h b/session_sid.h index 5ee86a4..97fef4a 100644 --- a/session_sid.h +++ b/session_sid.h @@ -22,7 +22,7 @@ #include "session_api.h" #include "defs.h" #include -#include "intrusive_ptr.h" +#include #include "session_storage.h" namespace cppcms { @@ -32,7 +32,7 @@ namespace sessions { class CPPCMS_API session_sid : public session_api { public: - session_sid(intrusive_ptr s); + session_sid(booster::intrusive_ptr s); ~session_sid(); virtual void save(session_interface &,std::string const &data,time_t timeout,bool,bool); virtual bool load(session_interface &,std::string &data,time_t &timeout); @@ -44,7 +44,7 @@ namespace sessions { struct data; booster::hold_ptr d; - intrusive_ptr storage_; + booster::intrusive_ptr storage_; }; } // sessions diff --git a/session_storage.h b/session_storage.h index 189a39f..b68908c 100644 --- a/session_storage.h +++ b/session_storage.h @@ -20,9 +20,9 @@ #define CPPCMS_SESSION_STORAGE_H #include "defs.h" -#include "refcounted.h" +#include #include -#include "intrusive_ptr.h" +#include #include namespace cppcms { @@ -39,7 +39,7 @@ namespace sessions { class session_storage : public booster::noncopyable, - public refcounted + public booster::refcounted { public: /// @@ -67,7 +67,7 @@ namespace sessions { class session_storage_factory { public: - virtual intrusive_ptr get() = 0; + virtual booster::intrusive_ptr get() = 0; virtual bool requires_gc() = 0; virtual void gc_job() {} virtual ~session_storage_factory() {} diff --git a/session_tcp_storage.cpp b/session_tcp_storage.cpp index f94efea..c9e8305 100644 --- a/session_tcp_storage.cpp +++ b/session_tcp_storage.cpp @@ -83,10 +83,10 @@ struct builder { ips(ips_), ports(ports_) { } - boost::shared_ptr operator()(worker_thread &w) + booster::shared_ptr operator()(worker_thread &w) { - boost::shared_ptr storage(new session_tcp_storage(ips,ports)); - return boost::shared_ptr(new session_sid(storage)); + booster::shared_ptr storage(new session_tcp_storage(ips,ports)); + return booster::shared_ptr(new session_sid(storage)); } } ; diff --git a/session_win32_file_storage.cpp b/session_win32_file_storage.cpp index 237c6db..22190e3 100644 --- a/session_win32_file_storage.cpp +++ b/session_win32_file_storage.cpp @@ -257,7 +257,7 @@ session_file_storage_factory::~session_file_storage_factory() { } -intrusive_ptr session_file_storage_factory::get() +booster::intrusive_ptr session_file_storage_factory::get() { return storage_; } diff --git a/session_win32_file_storage.h b/session_win32_file_storage.h index de44ac8..48a3b4a 100644 --- a/session_win32_file_storage.h +++ b/session_win32_file_storage.h @@ -61,13 +61,13 @@ namespace sessions { class CPPCMS_API session_file_storage_factory : public session_storage_factory { public: session_file_storage_factory(std::string path); - virtual intrusive_ptr get(); + virtual booster::intrusive_ptr get(); virtual bool requires_gc(); virtual void gc_job(); virtual ~session_file_storage_factory(); private: struct data; - intrusive_ptr storage_; + booster::intrusive_ptr storage_; }; } // sessions } // cppcms diff --git a/tcp_cache_server.cpp b/tcp_cache_server.cpp index 71e502e..27cd9ad 100644 --- a/tcp_cache_server.cpp +++ b/tcp_cache_server.cpp @@ -32,14 +32,12 @@ #include "config.h" #ifdef CPPCMS_USE_EXTERNAL_BOOST # include -# include -# include #else // Internal Boost # include -# include -# include namespace boost = cppcms_boost; #endif +#include +#include #include #include #include @@ -57,7 +55,7 @@ namespace impl { namespace io = booster::aio; -class tcp_cache_service::session : public boost::enable_shared_from_this { +class tcp_cache_service::session : public booster::enable_shared_from_this { std::vector data_in; std::string data_out; cppcms::impl::tcp_operation_header hout; @@ -279,7 +277,7 @@ class tcp_cache_service::server { io::socket acceptor_; cppcms::impl::base_cache &cache; //session_server_storage &sessions; - void on_accept(booster::system::error_code const &e,boost::shared_ptr s) + void on_accept(booster::system::error_code const &e,booster::shared_ptr s) { if(!e) { s->socket_.set_option(io::socket::tcp_no_delay,true); @@ -289,8 +287,8 @@ class tcp_cache_service::server { } void start_accept() { - //boost::shared_ptr s(new session(acceptor_.io_service(),cache,sessions)); - boost::shared_ptr s(new session(acceptor_.get_io_service(),cache)); + //booster::shared_ptr s(new session(acceptor_.io_service(),cache,sessions)); + booster::shared_ptr s(new session(acceptor_.get_io_service(),cache)); acceptor_.async_accept(s->socket_,boost::bind(&server::on_accept,this,_1,s)); } public: @@ -317,7 +315,7 @@ public: class garbage_collector { aio::deadline_timer timer; - boost::shared_ptr io; + booster::shared_ptr io; int seconds; void submit() { @@ -330,7 +328,7 @@ class garbage_collector submit(); } public: - garbage_collector(io::io_service &srv,int sec,boost::shared_ptr io_) : + garbage_collector(io::io_service &srv,int sec,booster::shared_ptr io_) : timer(srv), seconds(sec), io(io_) @@ -370,11 +368,11 @@ static void thread_function(io::io_service *io) struct tcp_cache_service::data { io::io_service io; std::auto_ptr srv_cache; - intrusive_ptr cache; - std::vector > threads; + booster::intrusive_ptr cache; + std::vector > threads; }; -tcp_cache_service::tcp_cache_service(intrusive_ptr cache,int threads,std::string ip,int port) : +tcp_cache_service::tcp_cache_service(booster::intrusive_ptr cache,int threads,std::string ip,int port) : d(new data) { d->cache=cache; @@ -388,7 +386,7 @@ tcp_cache_service::tcp_cache_service(intrusive_ptr cache,int threads int i; for(i=0;i thread; + booster::shared_ptr thread; thread.reset(new booster::thread(boost::bind(thread_function,&d->io))); d->threads.push_back(thread); } diff --git a/tcp_cache_server.h b/tcp_cache_server.h index f6d2279..ef8e16d 100644 --- a/tcp_cache_server.h +++ b/tcp_cache_server.h @@ -22,7 +22,7 @@ #include "defs.h" #include "base_cache.h" #include -#include "intrusive_ptr.h" +#include #include namespace cppcms { @@ -30,7 +30,7 @@ namespace impl { class CPPCMS_API tcp_cache_service : public booster::noncopyable { public: - tcp_cache_service(intrusive_ptr cache,int threads,std::string ip,int port); + tcp_cache_service(booster::intrusive_ptr cache,int threads,std::string ip,int port); ~tcp_cache_service(); void stop(); private: diff --git a/tests/cache_backend_test.cpp b/tests/cache_backend_test.cpp index 155a177..338016d 100644 --- a/tests/cache_backend_test.cpp +++ b/tests/cache_backend_test.cpp @@ -21,7 +21,7 @@ #include "tcp_cache_server.h" #include "cache_over_ip.h" #include "base_cache.h" -#include "intrusive_ptr.h" +#include #include "test.h" #include #include @@ -36,7 +36,7 @@ void ssleep(int x) { sleep(x); } -void test_cache(cppcms::intrusive_ptr cache,bool test_generators=true) +void test_cache(booster::intrusive_ptr cache,bool test_generators=true) { std::string tmp; std::set tags; @@ -100,7 +100,7 @@ void test_cache(cppcms::intrusive_ptr cache,bool test_ } } -void test_two_clients(cppcms::intrusive_ptr c1,cppcms::intrusive_ptr c2) +void test_two_clients(booster::intrusive_ptr c1,booster::intrusive_ptr c2) { std::string tmp; std::set tags; diff --git a/tests/forwarder_test.cpp b/tests/forwarder_test.cpp index 5de4f25..928ebba 100644 --- a/tests/forwarder_test.cpp +++ b/tests/forwarder_test.cpp @@ -27,14 +27,7 @@ #include #include "client.h" -#include "config.h" -#ifdef CPPCMS_USE_EXTERNAL_BOOST -# include -#else // Internal Boost -# include - namespace boost = cppcms_boost; -#endif - +#include #include class unit_test : public cppcms::application @@ -86,7 +79,7 @@ public: } - boost::shared_ptr service() + booster::shared_ptr service() { return srv; } @@ -104,8 +97,8 @@ public: fw_ok=true; } private: - boost::shared_ptr srv; - cppcms::intrusive_ptr app_; + booster::shared_ptr srv; + booster::intrusive_ptr app_; }; diff --git a/tests/proto_test.cpp b/tests/proto_test.cpp index 2e6c88a..f39dfe7 100644 --- a/tests/proto_test.cpp +++ b/tests/proto_test.cpp @@ -60,7 +60,7 @@ int main(int argc,char **argv) { try { cppcms::service srv(argc,argv); - cppcms::intrusive_ptr app; + booster::intrusive_ptr app; if(!srv.settings().get("test.async",false)) { srv.applications_pool().mount( cppcms::applications_factory()); } diff --git a/tests/storage_test.cpp b/tests/storage_test.cpp index cbe6e64..08bf242 100644 --- a/tests/storage_test.cpp +++ b/tests/storage_test.cpp @@ -40,7 +40,7 @@ std::string dir = "./sessions"; std::string bs="0123456789abcdef0123456789abcde"; -void test(cppcms::intrusive_ptr storage) +void test(booster::intrusive_ptr storage) { time_t now=time(0)+3; storage->save(bs+"1",now,""); @@ -77,7 +77,7 @@ std::vector list_files() return files; } -void test_files(cppcms::intrusive_ptr storage, +void test_files(booster::intrusive_ptr storage, cppcms::sessions::session_storage_factory &f) { test(storage); @@ -107,7 +107,7 @@ void test_files(cppcms::intrusive_ptr storage int main() { try { - cppcms::intrusive_ptr storage; + booster::intrusive_ptr storage; using namespace cppcms::sessions; std::cout << "Testing memory storage" << std::endl; diff --git a/thread_pool.cpp b/thread_pool.cpp index dcd31b9..74a0d6d 100644 --- a/thread_pool.cpp +++ b/thread_pool.cpp @@ -22,14 +22,13 @@ #include #include "config.h" #ifdef CPPCMS_USE_EXTERNAL_BOOST -# include # include #else // Internal Boost -# include # include namespace boost = cppcms_boost; #endif +#include #include #if defined(CPPCMS_POSIX) @@ -88,7 +87,7 @@ namespace impl { } for(unsigned i=0;i thread=workers_[i]; + booster::shared_ptr thread=workers_[i]; workers_[i].reset(); if(thread) thread->join(); @@ -137,7 +136,7 @@ namespace impl { int job_id_; typedef std::list > > queue_type; queue_type queue_; - std::vector > workers_; + std::vector > workers_; }; diff --git a/url_dispatcher.cpp b/url_dispatcher.cpp index 1f2d08c..5a00d6c 100644 --- a/url_dispatcher.cpp +++ b/url_dispatcher.cpp @@ -21,14 +21,7 @@ #include "application.h" #include - -#include "config.h" -#ifdef CPPCMS_USE_EXTERNAL_BOOST -# include -#else // Internal Boost -# include - namespace boost = cppcms_boost; -#endif +#include namespace cppcms { @@ -120,17 +113,17 @@ namespace cppcms { template - boost::shared_ptr