move deleter to a separate file
This commit is contained in:
		
							
								
								
									
										1
									
								
								block.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								block.h
									
									
									
									
									
								
							@@ -120,7 +120,6 @@ namespace persistent_data {
 | 
				
			|||||||
			const_buffer &data() const;
 | 
								const_buffer &data() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		protected:
 | 
							protected:
 | 
				
			||||||
			friend class block_manager; // FIXME: still needed?
 | 
					 | 
				
			||||||
			block_manager<BlockSize> const &bm_;
 | 
								block_manager<BlockSize> const &bm_;
 | 
				
			||||||
			block_ptr block_;
 | 
								block_ptr block_;
 | 
				
			||||||
			unsigned *holders_;
 | 
								unsigned *holders_;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										13
									
								
								cache.h
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								cache.h
									
									
									
									
									
								
							@@ -1,6 +1,8 @@
 | 
				
			|||||||
#ifndef CACHE_H
 | 
					#ifndef CACHE_H
 | 
				
			||||||
#define CACHE_H
 | 
					#define CACHE_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "deleter.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <boost/intrusive/circular_list_algorithms.hpp>
 | 
					#include <boost/intrusive/circular_list_algorithms.hpp>
 | 
				
			||||||
#include <boost/intrusive/rbtree_algorithms.hpp>
 | 
					#include <boost/intrusive/rbtree_algorithms.hpp>
 | 
				
			||||||
#include <boost/optional.hpp>
 | 
					#include <boost/optional.hpp>
 | 
				
			||||||
@@ -11,18 +13,9 @@
 | 
				
			|||||||
//----------------------------------------------------------------
 | 
					//----------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace base {
 | 
					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()
 | 
						// ValueTraits needs to define value_type, key_type and a get_key()
 | 
				
			||||||
	// static function.  Commonly you will want value_type to be a
 | 
						// static function.  Commonly you will want value_type to be a
 | 
				
			||||||
	// shared_ptr, with any teardown specific stuff in the destructor.
 | 
						// shared_ptr, with any teardown specific stuff in the destructor.
 | 
				
			||||||
 | 
					 | 
				
			||||||
	template <typename ValueTraits>
 | 
						template <typename ValueTraits>
 | 
				
			||||||
	class cache {
 | 
						class cache {
 | 
				
			||||||
	public:
 | 
						public:
 | 
				
			||||||
@@ -180,7 +173,7 @@ namespace base {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	template <typename ValueTraits>
 | 
						template <typename ValueTraits>
 | 
				
			||||||
	cache<ValueTraits>::~cache() {
 | 
						cache<ValueTraits>::~cache() {
 | 
				
			||||||
		deleter<value_entry> d;
 | 
							utils::deleter<value_entry> d;
 | 
				
			||||||
		lookup_algo::clear_and_dispose(&lookup_header_, d);
 | 
							lookup_algo::clear_and_dispose(&lookup_header_, d);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										17
									
								
								deleter.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								deleter.h
									
									
									
									
									
										Normal 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
 | 
				
			||||||
		Reference in New Issue
	
	Block a user