LCOV - code coverage report
Current view: top level - include/memory_manager - manager.h (source / functions) Hit Total Coverage
Test: CoherentDB code coverage Lines: 4 5 80.0 %
Date: 2011-02-13 Functions: 2 6 33.3 %

          Line data    Source code
       1             : /*
       2             :  * (C) Copyright 2010 Xilexio
       3             :  *
       4             :  * This file is part of CoherentDB.
       5             :  *
       6             :  * CoherentDB is free software: you can redistribute it and/or modify it
       7             :  * under the terms of the GNU General Public License as published by
       8             :  * the Free Software Foundation, either version 3 of the License, or
       9             :  * (at your option) any later version.
      10             :  *
      11             :  * CoherentDB is distributed in the hope that it will be useful, but
      12             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      14             :  * General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU General Public
      17             :  * License along with CoherentDB. If not, see
      18             :  * http://www.gnu.org/licenses/.
      19             :  */
      20             : 
      21             : #ifndef MEMORY_MANAGER_H
      22             : #define MEMORY_MANAGER_H
      23             : 
      24             : #include <boost/noncopyable.hpp>
      25             : #include <boost/thread.hpp>
      26             : #include <exception>
      27             : #include <stdint.h>
      28             : 
      29             : namespace coherent
      30             : {
      31             : 
      32             : namespace config
      33             : {
      34             : class global_config;
      35             : }
      36             : 
      37             : namespace memory_manager
      38             : {
      39             : 
      40             : class out_of_total_memory : public std::exception
      41           0 : {
      42             :     virtual const char* what() const throw();
      43             : };
      44             : 
      45             : class memory_manager : private boost::noncopyable
      46             : {
      47             : public:
      48             :     ~memory_manager();
      49             : 
      50     4179877 :     size_t get_page_size() const throw()
      51             :     {
      52     4179877 :         return page_size;
      53             :     }
      54             : 
      55           8 :     size_t get_default_session_limit_bytes() const throw()
      56             :     {
      57           8 :         return default_session_limit_bytes;
      58             :     }
      59             : 
      60             :     void reserve_bytes(size_t bytes);
      61             :     void free_bytes(size_t bytes);
      62             : 
      63             :     /// Creates instance of memory manager. Must be invoked before any memory manager operations.
      64             :     static void init(const config::global_config& conf);
      65             :     static memory_manager* instance;
      66             : 
      67             : private:
      68             :     memory_manager(const config::global_config& conf);
      69             : 
      70             :     uint64_t reserved_bytes;
      71             :     mutable boost::mutex reserved_bytes_mutex;
      72             :     uint64_t limit_bytes;
      73             :     size_t page_size;
      74             :     size_t default_session_limit_bytes;
      75             : };
      76             : 
      77             : }
      78             : }
      79             : 
      80             : #endif

Generated by: LCOV version 1.9