RaftLib
0.3a
C++ Stream Processing Template Library
|
#include <pointer.hpp>
Public Member Functions | |
Pointer (const size_t cap) | |
Pointer (const std::size_t cap, const std::int8_t wrap_set) | |
Pointer (Pointer *other, const size_t new_cap) | |
Static Public Member Functions | |
static size_t | val (Pointer *ptr) |
static void | inc (Pointer *const ptr) |
static void | incBy (const size_t in, Pointer *const ptr) |
static size_t | wrapIndicator (Pointer *ptr) |
Copyright 2014 Jonathan Beard
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.
Pointer::Pointer | ( | const size_t | cap | ) |
Pointer - used to synchronize read and write pointers for the ring buffer. This class encapsulates wrapping.
Pointer::Pointer | ( | Pointer * | other, |
const size_t | new_cap | ||
) |
Pointer - used to snchronize read and write poitners for the ring buffer, this constructer is a copy constructor that copies an old Pointer object and sets a new max_capacity
other,const | Pointer&, the other pointer to be cpied |
new_cap,the | new max cap |
|
static |
inc - increments the pointer, takes care of wrapping the pointers as well so you don't run off the page
|
static |
incBy - increments the current pointer poisition by 'in' increments. To be used for range insertion and removal
in | - const size_t |
|
static |
val - returns the current value of val. Internally the function checks to ensure that any writes to the pointer have fully completed so that the value returned is ensured to be the correct one. This is important as it means the producer will only see a "conservative" estimate of how many items can be written and the consumer will only see a "conservative" estimate of how many items can be read.
|
static |
wrapIndiciator - returns the current wrap position, the read should never be ahead of the write, and at best they should be equal. This is used when determining to return max_cap or zero for the current queue size.