00001 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*- 00002 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab: 00003 * 00004 * Copyright (C) 2010 Jay Pipes <jaypipes@gmail.com> 00005 * 00006 * Authors: 00007 * 00008 * Jay Pipes <jaypipes@gmail.com> 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00023 */ 00024 00036 #include <config.h> 00037 #include "write_buffer.h" 00038 00039 #include <drizzled/errmsg_print.h> 00040 #include <drizzled/gettext.h> 00041 00042 #include <vector> 00043 00044 using namespace std; 00045 using namespace drizzled; 00046 00047 WriteBuffer::WriteBuffer() : 00048 buffer() 00049 { 00050 buffer.reserve(DEFAULT_WRITE_BUFFER_SIZE); 00051 pthread_mutex_init(&latch, NULL); 00052 } 00053 00054 WriteBuffer::~WriteBuffer() 00055 { 00056 buffer.clear(); 00057 pthread_mutex_destroy(&latch); 00058 } 00059 00060 void WriteBuffer::resize(size_t new_size) 00061 { 00062 /* 00063 * Attempt allocation of raw memory buffer for the 00064 * requested size. Does nothing if already allocated size 00065 * if greater... 00066 */ 00067 if (buffer.capacity() >= new_size) 00068 return; 00069 00070 buffer.reserve(new_size); 00071 }