|
|
|
@ -1,5 +1,19 @@ |
|
|
|
|
#ifndef GRPC_SRC_CORE_UTIL_RING_BUFFER_H_ |
|
|
|
|
#define GRPC_SRC_CORE_UTIL_RING_BUFFER_H_ |
|
|
|
|
// Copyright 2024 gRPC authors.
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
#ifndef GRPC_SRC_CORE_UTIL_RING_BUFFER_H |
|
|
|
|
#define GRPC_SRC_CORE_UTIL_RING_BUFFER_H |
|
|
|
|
|
|
|
|
|
#include <grpc/support/port_platform.h> |
|
|
|
|
|
|
|
|
@ -50,9 +64,9 @@ class RingBuffer { |
|
|
|
|
|
|
|
|
|
T operator*() { return buffer_->data_[head_]; } |
|
|
|
|
|
|
|
|
|
RingBufferIterator() : buffer_(nullptr), head_(0), size_(0) {}; |
|
|
|
|
RingBufferIterator() : buffer_(nullptr), head_(0), size_(0){}; |
|
|
|
|
RingBufferIterator(const RingBufferIterator& other) = default; |
|
|
|
|
RingBufferIterator(const RingBuffer<T, kCapacity>* buffer) |
|
|
|
|
explicit RingBufferIterator(const RingBuffer<T, kCapacity>* buffer) |
|
|
|
|
: buffer_(buffer), head_(buffer->head_), size_(buffer->size_) { |
|
|
|
|
if (!size_) { |
|
|
|
|
buffer_ = nullptr; |
|
|
|
@ -106,4 +120,4 @@ class RingBuffer { |
|
|
|
|
|
|
|
|
|
} // namespace grpc_core
|
|
|
|
|
|
|
|
|
|
#endif // GRPC_SRC_CORE_UTIL_RING_BUFFER_H_
|
|
|
|
|
#endif // GRPC_SRC_CORE_UTIL_RING_BUFFER_H
|
|
|
|
|