move deleter to a separate file

This commit is contained in:
Joe Thornber 2011-11-08 10:30:13 +00:00
parent c6dbccd15a
commit 6dc6110684
3 changed files with 20 additions and 11 deletions

View File

@ -120,7 +120,6 @@ namespace persistent_data {
const_buffer &data() const;
protected:
friend class block_manager; // FIXME: still needed?
block_manager<BlockSize> const &bm_;
block_ptr block_;
unsigned *holders_;

13
cache.h
View File

@ -1,6 +1,8 @@
#ifndef CACHE_H
#define CACHE_H
#include "deleter.h"
#include <boost/intrusive/circular_list_algorithms.hpp>
#include <boost/intrusive/rbtree_algorithms.hpp>
#include <boost/optional.hpp>
@ -11,18 +13,9 @@
//----------------------------------------------------------------
namespace base {
// FIXME: move somewhere more useful
template <typename T>
struct deleter {
void operator()(T *t) {
delete t;
}
};
// ValueTraits needs to define value_type, key_type and a get_key()
// static function. Commonly you will want value_type to be a
// shared_ptr, with any teardown specific stuff in the destructor.
template <typename ValueTraits>
class cache {
public:
@ -180,7 +173,7 @@ namespace base {
template <typename ValueTraits>
cache<ValueTraits>::~cache() {
deleter<value_entry> d;
utils::deleter<value_entry> d;
lookup_algo::clear_and_dispose(&lookup_header_, d);
}

17
deleter.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef DELETER_H
#define DELETER_H
//----------------------------------------------------------------
namespace utils {
template <typename T>
struct deleter {
void operator()(T *t) {
delete t;
}
};
}
//----------------------------------------------------------------
#endif