MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
buffered_writer.h
1/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2miniob is licensed under Mulan PSL v2.
3You can use this software according to the terms and conditions of the Mulan PSL v2.
4You may obtain a copy of Mulan PSL v2 at:
5 http://license.coscl.org.cn/MulanPSL2
6THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9See the Mulan PSL v2 for more details. */
10
11//
12// Created by Wangyunlai on 2023/06/16.
13//
14
15#pragma once
16
17#include "net/ring_buffer.h"
18
26{
27public:
28 BufferedWriter(int fd);
29 BufferedWriter(int fd, int32_t size);
31
35 RC close();
36
44 RC write(const char *data, int32_t size, int32_t &write_size);
45
52 RC writen(const char *data, int32_t size);
53
58 RC flush();
59
60private:
67 RC flush_internal(int32_t size);
68
69private:
70 int fd_ = -1;
71 RingBuffer buffer_;
72};
支持以缓存模式写入数据到文件/socket
Definition: buffered_writer.h:26
RC close()
关闭缓存
Definition: buffered_writer.cpp:36
RC writen(const char *data, int32_t size)
写数据到文件/socket,全部写入成功返回成功
Definition: buffered_writer.cpp:68
RC write(const char *data, int32_t size, int32_t &write_size)
写数据到文件/socket
Definition: buffered_writer.cpp:52
RC flush()
刷新缓存
Definition: buffered_writer.cpp:88
RC flush_internal(int32_t size)
刷新缓存
Definition: buffered_writer.cpp:101
环形缓存,当前用于通讯写入数据时的缓存
Definition: ring_buffer.h:26