Imported Upstream version 1.57.0
[platform/upstream/boost.git] / boost / interprocess / mem_algo / detail / multi_simple_seq_fit.hpp
1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // See http://www.boost.org/libs/interprocess for documentation.
8 //
9 //////////////////////////////////////////////////////////////////////////////
10
11 #ifndef BOOST_INTERPROCESS_MULTI_SIMPLE_SEQ_FIT_HPP
12 #define BOOST_INTERPROCESS_MULTI_SIMPLE_SEQ_FIT_HPP
13
14 #if defined(_MSC_VER)
15 #  pragma once
16 #endif
17
18 #include <boost/interprocess/detail/config_begin.hpp>
19 #include <boost/interprocess/detail/workaround.hpp>
20
21 #include <boost/interprocess/interprocess_fwd.hpp>
22 #include <boost/interprocess/mem_algo/detail/simple_seq_fit_impl.hpp>
23 #include <boost/interprocess/intersegment_ptr.hpp>
24
25 /*!\file
26    Describes sequential fit algorithm used to allocate objects in shared memory.
27 */
28
29 namespace boost {
30
31 namespace interprocess {
32
33 /*!This class implements the simple sequential fit algorithm with a simply
34    linked list of free buffers.*/
35 template<class MutexFamily, class VoidPtr>
36 class multi_simple_seq_fit
37    : public ipcdetail::simple_seq_fit_impl<MutexFamily, VoidPtr>
38 {
39    typedef ipcdetail::simple_seq_fit_impl<MutexFamily, VoidPtr> base_t;
40  public:
41    /*!Constructor. "size" is the total size of the managed memory segment,
42       "extra_hdr_bytes" indicates the extra bytes beginning in the sizeof(multi_simple_seq_fit)
43       offset that the allocator should not use at all.*/
44    multi_simple_seq_fit           (size_type size, size_type extra_hdr_bytes)
45       : base_t(size, extra_hdr_bytes){}
46
47    /*!Allocates bytes from existing segments. If there is no memory, it uses
48       the growing functor associated with the group to allocate a new segment.
49       If this fails, returns 0.*/
50    void* allocate             (size_type nbytes)
51       {  return base_t::multi_allocate(nbytes);   }
52 };
53
54 }  //namespace interprocess {
55
56 }  //namespace boost {
57
58 #include <boost/interprocess/detail/config_end.hpp>
59
60 #endif   //#ifndef BOOST_INTERPROCESS_MULTI_SIMPLE_SEQ_FIT_HPP
61