0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 11:18:51 +02:00

ircd::buffer: Preliminary shared_buffer.

This commit is contained in:
Jason Volk 2018-03-13 11:21:19 -07:00
parent 3eadd31c7f
commit 80f4b7151f
2 changed files with 36 additions and 0 deletions

View file

@ -39,6 +39,7 @@ namespace ircd::buffer
struct window_buffer;
template<class buffer, size_t SIZE> struct fixed_buffer;
template<class buffer, uint align = 16> struct unique_buffer;
template<class buffer> struct shared_buffer;
template<size_t SIZE> using fixed_const_buffer = fixed_buffer<const_buffer, SIZE>;
template<size_t SIZE> using fixed_mutable_buffer = fixed_buffer<mutable_buffer, SIZE>;
@ -89,6 +90,7 @@ namespace ircd::buffer
#include "fixed_buffer.h"
#include "window_buffer.h"
#include "unique_buffer.h"
#include "shared_buffer.h"
// Export these important aliases down to main ircd namespace
namespace ircd
@ -97,6 +99,7 @@ namespace ircd
using buffer::mutable_buffer;
using buffer::fixed_buffer;
using buffer::unique_buffer;
using buffer::shared_buffer;
using buffer::null_buffer;
using buffer::window_buffer;
using buffer::fixed_const_buffer;

View file

@ -0,0 +1,33 @@
// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#pragma once
#define HAVE_IRCD_BUFFER_SHARED_BUFFER_H
template<class buffer>
struct ircd::buffer::shared_buffer
:std::shared_ptr<char>
,buffer
{
shared_buffer(const size_t &size);
shared_buffer() = default;
};
template<class buffer>
ircd::buffer::shared_buffer<buffer>::shared_buffer(const size_t &size)
:std::shared_ptr<char>
{
std::make_shared<char>(size)
}
,buffer
{
std::shared_ptr<char>::get(), size
}
{}