priv: remove unused allocator.hh
* spot/priv/allocator.hh: Delete. * spot/priv/Makefile.am, tests/core/mempool.cc: Adjust.
This commit is contained in:
parent
d0b1508831
commit
ba695194cd
3 changed files with 1 additions and 135 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
## -*- coding: utf-8 -*-
|
## -*- coding: utf-8 -*-
|
||||||
## Copyright (C) 2013-2019, 2021 Laboratoire de Recherche et
|
## Copyright (C) 2013-2019, 2021-2022 Laboratoire de Recherche et
|
||||||
## Développement de l'Epita (LRDE).
|
## Développement de l'Epita (LRDE).
|
||||||
##
|
##
|
||||||
## This file is part of Spot, a model checking library.
|
## This file is part of Spot, a model checking library.
|
||||||
|
|
@ -24,7 +24,6 @@ AM_CXXFLAGS = $(WARNING_CXXFLAGS)
|
||||||
noinst_LTLIBRARIES = libpriv.la
|
noinst_LTLIBRARIES = libpriv.la
|
||||||
libpriv_la_SOURCES = \
|
libpriv_la_SOURCES = \
|
||||||
accmap.hh \
|
accmap.hh \
|
||||||
allocator.hh \
|
|
||||||
bddalloc.cc \
|
bddalloc.cc \
|
||||||
bddalloc.hh \
|
bddalloc.hh \
|
||||||
freelist.cc \
|
freelist.cc \
|
||||||
|
|
|
||||||
|
|
@ -1,104 +0,0 @@
|
||||||
// -*- coding: utf-8 -*-
|
|
||||||
// Copyright (C) 2011, 2015-2018 Laboratoire de Recherche et
|
|
||||||
// Développement de l'Epita (LRDE)
|
|
||||||
//
|
|
||||||
// This file is part of Spot, a model checking library.
|
|
||||||
//
|
|
||||||
// Spot is free software; you can redistribute it and/or modify it
|
|
||||||
// under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation; either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// Spot 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 General Public
|
|
||||||
// License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <spot/misc/fixpool.hh>
|
|
||||||
|
|
||||||
namespace spot
|
|
||||||
{
|
|
||||||
/// An allocator to be used with STL containers.
|
|
||||||
/// It uses a spot::fixed_size_pool to handle memory.
|
|
||||||
/// It is intended to improve performance and locality of node-based
|
|
||||||
/// containers (std::{unordered}{multi}{set,map}).
|
|
||||||
/// It is geared towards efficiently allocating memory for one object at a
|
|
||||||
/// time (the nodes of the node-based containers). Larger allocations are
|
|
||||||
/// served by calling the global memory allocation mechanism (::operator new).
|
|
||||||
/// Using it for contiguous containers (such as std::vector or std::deque)
|
|
||||||
/// will be less efficient than using the default std::allocator.
|
|
||||||
///
|
|
||||||
/// Short reminder on STL concept of Allocator:
|
|
||||||
/// allocate() may throw
|
|
||||||
/// deallocate() must not throw
|
|
||||||
/// equality testing (i.e. == and !=) must not throw
|
|
||||||
/// copying allocator (constructor and assignment) must not throw
|
|
||||||
/// moving allocator (constructor and assignment) must not throw
|
|
||||||
///
|
|
||||||
/// WARNING this class is NOT thread-safe: the allocator relies on a static
|
|
||||||
/// fixed_size_pool (which is not thread-safe either).
|
|
||||||
template<class T>
|
|
||||||
class pool_allocator
|
|
||||||
{
|
|
||||||
static
|
|
||||||
fixed_size_pool<pool_type::Safe>&
|
|
||||||
pool()
|
|
||||||
{
|
|
||||||
static fixed_size_pool<pool_type::Safe> p =
|
|
||||||
fixed_size_pool<pool_type::Safe>(sizeof(T));
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
using value_type = T;
|
|
||||||
using pointer = value_type*;
|
|
||||||
using const_pointer = const value_type*;
|
|
||||||
using size_type = size_t;
|
|
||||||
|
|
||||||
constexpr pool_allocator() noexcept
|
|
||||||
{}
|
|
||||||
template<class U>
|
|
||||||
constexpr pool_allocator(const pool_allocator<U>&) noexcept
|
|
||||||
{}
|
|
||||||
|
|
||||||
template<class U>
|
|
||||||
struct rebind
|
|
||||||
{
|
|
||||||
using other = pool_allocator<U>;
|
|
||||||
};
|
|
||||||
|
|
||||||
pointer
|
|
||||||
allocate(size_type n)
|
|
||||||
{
|
|
||||||
if (SPOT_LIKELY(n == 1))
|
|
||||||
return static_cast<pointer>(pool().allocate());
|
|
||||||
else
|
|
||||||
return static_cast<pointer>(::operator new(n*sizeof(T)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
deallocate(pointer ptr, size_type n) noexcept
|
|
||||||
{
|
|
||||||
if (SPOT_LIKELY(n == 1))
|
|
||||||
pool().deallocate(static_cast<void*>(ptr));
|
|
||||||
else
|
|
||||||
::operator delete(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
operator==(const pool_allocator&) const noexcept
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool
|
|
||||||
operator!=(const pool_allocator& o) const noexcept
|
|
||||||
{
|
|
||||||
return !(this->operator==(o));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -23,9 +23,6 @@
|
||||||
|
|
||||||
#include <spot/misc/fixpool.hh>
|
#include <spot/misc/fixpool.hh>
|
||||||
#include <spot/misc/mspool.hh>
|
#include <spot/misc/mspool.hh>
|
||||||
#include <spot/priv/allocator.hh>
|
|
||||||
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
@ -157,32 +154,6 @@ int main()
|
||||||
c->incr();
|
c->incr();
|
||||||
// no delete: valgrind should find a leak
|
// no delete: valgrind should find a leak
|
||||||
}
|
}
|
||||||
{
|
|
||||||
std::set<int, std::less<int>, spot::pool_allocator<int>> s;
|
|
||||||
s.insert(1);
|
|
||||||
s.insert(2);
|
|
||||||
s.insert(1);
|
|
||||||
s.erase(1);
|
|
||||||
s.insert(3);
|
|
||||||
s.insert(4);
|
|
||||||
|
|
||||||
s.clear();
|
|
||||||
|
|
||||||
auto t = s;
|
|
||||||
t.insert(5);
|
|
||||||
t.insert(6);
|
|
||||||
|
|
||||||
std::swap(s, t);
|
|
||||||
|
|
||||||
s.erase(5);
|
|
||||||
s.erase(6);
|
|
||||||
|
|
||||||
if (s != t)
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue