libfoedus-core
FOEDUS Core Library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
log_type_invoke.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
18 #ifndef FOEDUS_LOG_LOG_TYPE_INVOKE_HPP_
19 #define FOEDUS_LOG_LOG_TYPE_INVOKE_HPP_
20 #include <iosfwd>
21 
22 #include "foedus/assert_nd.hpp"
23 #include "foedus/log/log_type.hpp"
24 #include "foedus/thread/fwd.hpp"
25 #include "foedus/xct/xct_id.hpp"
26 
27 // include all header files that declare log types defined in the xmacro.
28 // unlike log_type.hpp, we need full declarations here. so this file would be big.
29 #include "foedus/log/common_log_types.hpp" // NOLINT(build/include_alpha)
35 
36 namespace foedus {
37 namespace log {
38 
45 void invoke_apply_engine(void *log_buffer, thread::Thread* context);
46 
53 void invoke_apply_storage(void *log_buffer, Engine* engine, storage::StorageId id);
54 
62  void *log_buffer,
63  thread::Thread* context,
64  storage::StorageId storage_id,
65  xct::RwLockableXctId* owner_id_address,
66  char* payload_address);
67 
75 void invoke_assert_valid(void *log_buffer);
76 
85 void invoke_ostream(const void *buffer, std::ostream *ptr);
86 
87 #define X(a, b, c) case a: \
88  reinterpret_cast< c* >(buffer)->apply_record(context, storage_id, owner_id, payload); return;
89 inline void invoke_apply_record(
90  void *buffer,
91  thread::Thread* context,
92  storage::StorageId storage_id,
93  xct::RwLockableXctId* owner_id,
94  char* payload) {
95  invoke_assert_valid(buffer);
96  LogHeader* header = reinterpret_cast<LogHeader*>(buffer);
97  LogCode code = header->get_type();
98  switch (code) {
99 #include "foedus/log/log_type.xmacro" // NOLINT
100  default:
101  ASSERT_ND(false);
102  return;
103  }
104 }
105 #undef X
106 
107 #ifdef NDEBUG
108 inline void invoke_assert_valid(void* /*buffer*/) {}
109 #else // NDEBUG
110 #define X(a, b, c) case a: reinterpret_cast< c* >(buffer)->assert_valid(); return;
111 inline void invoke_assert_valid(void *buffer) {
112  LogHeader* header = reinterpret_cast<LogHeader*>(buffer);
113  LogCode code = header->get_type();
114  switch (code) {
115 #include "foedus/log/log_type.xmacro" // NOLINT
116  default:
117  ASSERT_ND(false);
118  return;
119  }
120 }
121 #undef X
122 #endif // NDEBUG
123 
124 } // namespace log
125 } // namespace foedus
126 
127 #endif // FOEDUS_LOG_LOG_TYPE_INVOKE_HPP_
LogCode
A unique identifier of all log types.
Definition: log_type.hpp:87
Declares all log types used in this storage type.
uint32_t StorageId
Unique ID for storage.
Definition: storage_id.hpp:55
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
Represents one thread running on one NUMA core.
Definition: thread.hpp:48
void invoke_apply_engine(void *log_buffer, thread::Thread *context)
Invokes the apply logic for an engine-wide log type.
Declares all log types used in this storage type.
void invoke_assert_valid(void *log_buffer)
Invokes the assertion logic of each log type.
void invoke_apply_storage(void *log_buffer, Engine *engine, storage::StorageId id)
Invokes the apply logic for a storage-wide log type.
Declares common log types used in all packages.
The MCS reader-writer lock variant of LockableXctId.
Definition: xct_id.hpp:1132
Declares common log types for all (or at least multiple) storage types.
Definitions of IDs in this package and a few related constant values.
Declares all log types used in this storage type.
A common header part for all log types.
Declares all log types used in this storage type.
void invoke_ostream(const void *buffer, std::ostream *ptr)
Invokes the ostream operator for the given log type defined in log_type.xmacro.
LogCode get_type() const __attribute__((always_inline))
Convenience method to cast into LogCode.
void invoke_apply_record(void *log_buffer, thread::Thread *context, storage::StorageId storage_id, xct::RwLockableXctId *owner_id_address, char *payload_address)
Invokes the apply logic for a record-wise log type.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72
Forward declarations of classes in thread package.