- Main Page
- Classes
- Files

- File List

# include/pion/process.hpp

    00001 // ---------------------------------------------------------------------
    00002 // pion:  a Boost C++ framework for building lightweight HTTP interfaces
    00003 // ---------------------------------------------------------------------
    00004 // Copyright (C) 2007-2012 Cloudmeter, Inc.  (http://www.cloudmeter.com)
    00005 //
    00006 // Distributed under the Boost Software License, Version 1.0.
    00007 // See http://www.boost.org/LICENSE_1_0.txt
    00008 //
    00009
    00010 #ifndef __PION_PROCESS_HEADER__
    00011 #define __PION_PROCESS_HEADER__
    00012
    00013 #include <string>
    00014 #include <boost/noncopyable.hpp>
    00015 #include <boost/thread/once.hpp>
    00016 #include <boost/thread/mutex.hpp>
    00017 #include <boost/thread/condition.hpp>
    00018 #include <pion/config.hpp>
    00019
    00020
    00021 namespace pion {    // begin namespace pion
    00022
    00026 class PION_API process :
    00027     private boost::noncopyable
    00028 {
    00029 public:
    00030
    00031     // default destructor
    00032     ~process() {}
    00033
    00035     process(void) {}
    00036
    00038     static void shutdown(void);
    00039
    00041     static void wait_for_shutdown(void);
    00042
    00044     static void initialize(void);
    00045
    00047     static void daemonize(void);
    00048
    00049
    00050 protected:
    00051
    00053     struct config_type {
    00055         config_type() : shutdown_now(false) {}
    00056
    00058         bool                    shutdown_now;
    00059
    00061         boost::condition        shutdown_cond;
    00062
    00064         boost::mutex            shutdown_mutex;
    00065     };
    00066
    00067
    00069     static inline config_type& get_config(void) {
    00070         boost::call_once(process::create_config, m_instance_flag);
    00071         return *m_config_ptr;
    00072     }
    00073
    00074
    00075 private:
    00076
    00078     static void create_config(void);
    00079
    00080
    00082     static boost::once_flag             m_instance_flag;
    00083
    00085     static config_type *          m_config_ptr;
    00086 };
    00087
    00088
    00089 }   // end namespace pion
    00090
    00091 #endif