GraphLab: Distributed Graph-Parallel API  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cache_line_pad.hpp
1 /**
2  * Copyright (c) 2009 Carnegie Mellon University.
3  * All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an "AS
13  * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14  * express or implied. See the License for the specific language
15  * governing permissions and limitations under the License.
16  *
17  * For more about this software visit:
18  *
19  * http://www.graphlab.ml.cmu.edu
20  *
21  */
22 
23 /**
24  * Also contains code that is Copyright 2011 Yahoo! Inc. All rights
25  * reserved.
26  *
27  * Contributed under the iCLA for:
28  * Joseph Gonzalez ([email protected])
29  *
30  */
31 
32 
33 
34 
35 
36 #ifndef GRAPHLAB_CACHE_LINE_PAD
37 #define GRAPHLAB_CACHE_LINE_PAD
38 
39 namespace graphlab {
40  /**
41  * Used to prevent false cache sharing by padding T
42  */
43  template <typename T> struct cache_line_pad {
44  T value;
45  char pad[64 - (sizeof(T) % 64)];
46  cache_line_pad(const T& value = T()) : value(value) { }
47  T& operator=(const T& other) { return value = other; }
48  operator T() const { return value; }
49  }; // end of cache_line_pad
50 
51 }; // end of namespace
52 
53 
54 
55 
56 
57 #endif