58107796dcdef0f12e191f621b77979192210826
[libcds.git] / test / include / cds_test / fc_hevy_value.h
1 /*
2  * fc_hevy_value.h
3  *
4  *  Created on: 31 авг. 2016 г.
5  *      Author: marsel
6  */
7
8 #ifndef SOURCE_DIRECTORY__TEST_INCLUDE_CDS_TEST_FC_HEAVY_VALUE_H_
9 #define SOURCE_DIRECTORY__TEST_INCLUDE_CDS_TEST_FC_HEAVY_VALUE_H_
10
11 #include <math.h>
12 #include <vector>
13
14 namespace{
15     template<int DefaultSize = 10>
16     struct HeavyValue {
17
18         int value;
19
20         size_t nNo;
21         size_t nWriterNo;
22
23         static std::vector<int> pop_buff;
24         static std::vector<int>::size_type buffer_size;
25
26         explicit HeavyValue(int new_value = 0)
27         : value(new_value),
28           nNo(0),
29           nWriterNo(0)
30         {
31         };
32         HeavyValue(const HeavyValue &other)
33             : value(other.value),
34               nNo(other.nNo),
35               nWriterNo(other.nWriterNo)
36         {
37             for(decltype(buffer_size) i = 0; i < buffer_size; ++i)
38                 pop_buff[i] =  static_cast<int>(std::sqrt(other.pop_buff[i]*rand()));
39         }
40         static void setArraySize(decltype(buffer_size) new_size){
41             buffer_size = new_size;
42             pop_buff.resize(buffer_size, rand());
43         }
44     };
45     template<int DefaultSize>
46     std::vector<int> HeavyValue< DefaultSize >::pop_buff(DefaultSize, rand());
47     template<int DefaultSize>
48     std::vector<int>::size_type HeavyValue< DefaultSize >::buffer_size = DefaultSize;
49 }
50 #endif /* SOURCE_DIRECTORY__TEST_INCLUDE_CDS_TEST_FC_HEVY_VALUE_H_ */