pool: use std::size_t in preference to unsigned for capacity
This commit is contained in:
parent
c34002ae07
commit
78f746c21e
24
pool.hpp
24
pool.hpp
@ -16,7 +16,7 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace cruft {
|
namespace cruft {
|
||||||
@ -43,7 +43,7 @@ namespace cruft {
|
|||||||
std::atomic<node *> m_next;
|
std::atomic<node *> m_next;
|
||||||
|
|
||||||
// the total number of items that could be stored
|
// the total number of items that could be stored
|
||||||
const size_t m_capacity;
|
std::size_t m_capacity;
|
||||||
|
|
||||||
// the number of items currently stored.
|
// the number of items currently stored.
|
||||||
std::atomic<size_t> m_size;
|
std::atomic<size_t> m_size;
|
||||||
@ -56,7 +56,7 @@ namespace cruft {
|
|||||||
pool& operator= (pool&&);
|
pool& operator= (pool&&);
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
pool (unsigned int _capacity):
|
pool (std::size_t _capacity):
|
||||||
m_capacity (_capacity),
|
m_capacity (_capacity),
|
||||||
m_size (0u)
|
m_size (0u)
|
||||||
{
|
{
|
||||||
@ -141,22 +141,10 @@ namespace cruft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t capacity (void) const
|
auto capacity (void) const { return m_capacity; }
|
||||||
{
|
auto size (void) const { return m_size.load (); }
|
||||||
return m_capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
bool empty (void) const { return m_size == m_capacity; }
|
||||||
size_t size (void) const
|
|
||||||
{
|
|
||||||
return m_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool empty (void) const
|
|
||||||
{
|
|
||||||
return m_size == m_capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Indexing
|
// Indexing
|
||||||
|
@ -23,7 +23,8 @@ check_single (cruft::TAP::logger &tap)
|
|||||||
void
|
void
|
||||||
check_unique_ptr (cruft::TAP::logger &tap)
|
check_unique_ptr (cruft::TAP::logger &tap)
|
||||||
{
|
{
|
||||||
cruft::pool<uint64_t> uintpool (1025);
|
constexpr std::size_t element_count = 1025;
|
||||||
|
cruft::pool<uint64_t> uintpool (element_count);
|
||||||
std::set<uint64_t *> uintset;
|
std::set<uint64_t *> uintset;
|
||||||
|
|
||||||
// Take all pointers out, checking they are unique, then replace for destruction.
|
// Take all pointers out, checking they are unique, then replace for destruction.
|
||||||
|
Loading…
Reference in New Issue
Block a user