1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (c) 2010 Jay Pipes <jaypipes@gmail.com>
8
* Jay Pipes <jaypipes@gmail.com>
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
* Defines a simple structure for maintaining a write buffer.
31
#ifndef PLUGIN_TRANSACTION_LOG_WRITE_BUFFER_H
32
#define PLUGIN_TRANSACTION_LOG_WRITE_BUFFER_H
41
static const size_t DEFAULT_WRITE_BUFFER_SIZE= 1024; /* Many GPB messages are < 1 KB... */
48
* Locks the log write buffer
52
pthread_mutex_lock(&latch);
55
* Unlocks the log's write buffer
59
pthread_mutex_unlock(&latch);
62
* Resizes the internal raw byte buffer
64
* @param[in] New size to allocate
66
void resize(size_t new_size);
68
* Returns the pointer to the raw bytes.
70
uint8_t *getRawBytes()
75
* Returns the size of the write buffer
83
WriteBuffer(const WriteBuffer&);
84
WriteBuffer &operator=(const WriteBuffer&);
86
uint8_t *buffer; ///< Raw memory buffer managed by the log
87
size_t buffer_size; ///< Current size of write buffer
88
pthread_mutex_t latch; ///< Lock around the synchronized parts of the log (the write buffer)
91
#endif /* PLUGIN_TRANSACTION_LOG_UNDO_LOG_H */