Line data Source code
1 : //
2 : // Author: Vladimir Migashko <migashko@gmail.com>, (C) 2012
3 : //
4 : // Copyright: See COPYING file that comes with this distribution
5 : //
6 :
7 : #ifndef VSET_VSET_BUFFER_PERSISTENT_FILESYNC_AD_RESIZE_HPP
8 : #define VSET_VSET_BUFFER_PERSISTENT_FILESYNC_AD_RESIZE_HPP
9 :
10 : #include <vset/buffer/tags.hpp>
11 : #include <vset/buffer/persistent/tags.hpp>
12 : #include <iostream>
13 : #include <stdlib.h>
14 :
15 :
16 : namespace vset { namespace buffer { namespace persistent{ namespace filesync{
17 :
18 3 : struct ad_resize
19 : {
20 : template<typename T>
21 2 : void operator()( T& t, size_t size)
22 : {
23 2 : size_t capacity = t.get_aspect().template get<_capacity_>()(t);
24 2 : if ( size <= capacity )
25 : {
26 1 : t.get_aspect().template get<_head_>()(t)->set_size(size);
27 1 : t.get_aspect().template get<_size_value_>()=size;
28 3 : return;
29 : }
30 1 : t.get_aspect().template get<_head_>()(t)->set_size(size);
31 1 : t.get_aspect().template get<_size_value_>()=size;
32 1 : if (size > capacity)
33 : {
34 1 : t.get_aspect().template get<_head_>()(t)->set_capacity(size);
35 1 : t.get_aspect().template get<_capacity_value_>()=size;
36 : }
37 1 : t.get_aspect().template get<_sync_>()(t);
38 1 : t.get_aspect().template get<_open_>()(t);
39 : }
40 : };
41 :
42 : }}}}
43 :
44 : #endif
|