|
Open Model Railroad Network (OpenMRN)
|
#include <memory>#include <atomic>#include <new>#include <cstdint>#include <cstdlib>#include <cstdarg>#include "executor/Executable.hxx"#include "executor/Notifiable.hxx"#include "os/OS.hxx"#include "utils/Atomic.hxx"#include "utils/MultiMap.hxx"#include "utils/QMember.hxx"#include "utils/Queue.hxx"#include "utils/macros.h"Go to the source code of this file.
Classes | |
| class | BufferBase |
| Abstract base class for all Buffers. More... | |
| class | Buffer< T > |
| Base class for all QMember types that hold data in an expandable format. More... | |
| struct | BufferDelete< T > |
| Helper class for correctly deleting a buffer. More... | |
| class | Pool |
| Pool of previously allocated, but currently unused, items. More... | |
| class | Bucket |
| This is a struct for storing info about a specific size item in the DynamicPool. More... | |
| class | DynamicPool |
| A specialization of a pool which can allocate new elements dynamically upon request. More... | |
| class | FixedPool |
| Pool of fixed number of items which can be allocated up on request. More... | |
Namespaces | |
| namespace | openlcb |
Typedefs | |
| template<typename T > | |
| using | AutoReleaseBuffer = std::unique_ptr< Buffer< T >, BufferDelete< T > > |
| This class will automatically unref a Buffer when going out of scope. | |
| template<typename T > | |
| using | BufferPtr = AutoReleaseBuffer< T > |
| Smart pointer for buffers. | |
Functions | |
| Pool * | init_main_buffer_pool () |
| Initializes the main buffer pool. | |
| template<typename T > | |
| BufferPtr< T > | get_buffer_deleter (Buffer< T > *b) |
| Helper function to create a BufferPtr of an appropriate type without having to explicitly specify the template argument. | |
Variables | |
| const unsigned | LARGEST_BUFFERPOOL_BUCKET |
| Ensures that the largest bucket in the main buffer pool is exactly the size of a GenMessage. | |
| DynamicPool * | mainBufferPool |
| main buffer pool instance | |
| void * | g_current_alloc |
| This pointer will be saved for debugging the current allocation source. | |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file provides buffers with allocation and freelist/reuse mechanisms.
Definition in file Buffer.hxx.
| using AutoReleaseBuffer = std::unique_ptr<Buffer<T>, BufferDelete<T> > |
This class will automatically unref a Buffer when going out of scope.
Definition at line 256 of file Buffer.hxx.
| using BufferPtr = AutoReleaseBuffer<T> |
Smart pointer for buffers.
This class will automatically unref a Buffer when going out of scope.
Definition at line 259 of file Buffer.hxx.
Helper function to create a BufferPtr of an appropriate type without having to explicitly specify the template argument.
Example usage: Action foo() { // after an allocate_and_call(barFlow_, STATE(foo)); auto b = get_buffer_deleter(get_allocation_result(barFlow_)); ... // maybe return call_immediately(throw_error); b->data()->qux = 13; // use b regularly as if it was a pointer. barFlow_->send(b.transfer()); }
| b | is the typed raw buffer pointer. |
Definition at line 272 of file Buffer.hxx.
| Pool * init_main_buffer_pool | ( | ) |
Initializes the main buffer pool.
The first call is not thread safe, later calls are noops. It is recommended to call this one or more times from the static initialization.
Definition at line 40 of file Buffer.cxx.
|
extern |
|
extern |
main buffer pool instance
Definition at line 37 of file Buffer.cxx.