-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add llfs::IoRingStreamBuffer. (#139)
* IoRingBufferView tests. * Clean up IoRingStreamBuffer impl; need to write test plan. * Clean up IoRingBufferPool; add IoRingBufferView::{split,data,size}. * Wrote IoRingStreamBuffer tests; doing line/cond coverage testing now. * Finished coverage testing of IoRingStreamBuffer (for now). Ready for MR! * Remove a spurious (formatting) diff.
- Loading branch information
1 parent
838b62f
commit 16fa593
Showing
14 changed files
with
2,039 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//#=##=##=#==#=#==#===#+==#+==========+==+=+=+=+=+=++=+++=+++++=-++++=-+++++++++++ | ||
// | ||
// Part of the LLFS Project, under Apache License v2.0. | ||
// See https://www.apache.org/licenses/LICENSE-2.0 for license information. | ||
// SPDX short identifier: Apache-2.0 | ||
// | ||
//+++++++++++-+-+--+----- --- -- - - - - | ||
|
||
#include <llfs/buffer.hpp> | ||
// | ||
#include <llfs/buffer.hpp> | ||
|
||
#include <gmock/gmock.h> | ||
#include <gtest/gtest.h> | ||
|
||
namespace { | ||
|
||
using namespace llfs::int_types; | ||
|
||
TEST(BufferTest, ResizeBufferStorage) | ||
{ | ||
std::unique_ptr<u8[]> storage; | ||
llfs::MutableBuffer buffer = resize_buffer_storage(storage, 1977); | ||
|
||
EXPECT_NE(buffer.data(), nullptr); | ||
EXPECT_EQ((void*)buffer.data(), (void*)storage.get()); | ||
EXPECT_EQ(buffer.size(), 1977u); | ||
} | ||
|
||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
//#=##=##=#==#=#==#===#+==#+==========+==+=+=+=+=+=++=+++=+++++=-++++=-+++++++++++ | ||
// | ||
// Part of the LLFS Project, under Apache License v2.0. | ||
// See https://www.apache.org/licenses/LICENSE-2.0 for license information. | ||
// SPDX short identifier: Apache-2.0 | ||
// | ||
//+++++++++++-+-+--+----- --- -- - - - - | ||
|
||
#include <llfs/ioring_buffer_view.hpp> | ||
// | ||
|
||
namespace llfs { | ||
|
||
//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - - | ||
// | ||
template <typename SliceT> | ||
auto BasicIoRingBufferView<SliceT>::split(usize byte_offset) noexcept -> Self | ||
{ | ||
byte_offset = std::min(byte_offset, this->slice.size()); | ||
|
||
Self prefix{ | ||
this->buffer, | ||
SliceT{this->slice.data(), byte_offset}, | ||
}; | ||
|
||
this->slice += byte_offset; | ||
|
||
return prefix; | ||
} | ||
|
||
//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - - | ||
// | ||
template <typename SliceT> | ||
bool BasicIoRingBufferView<SliceT>::can_merge_with(const Self& other) const noexcept | ||
{ | ||
return this->buffer == other.buffer // | ||
&& get_buffer_end(this->slice) == other.slice.data(); | ||
} | ||
|
||
//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - - | ||
// | ||
template <typename SliceT> | ||
bool BasicIoRingBufferView<SliceT>::merge_with(const Self& other) noexcept | ||
{ | ||
if (!this->can_merge_with(other)) { | ||
return false; | ||
} | ||
this->slice = SliceT{ | ||
this->slice.data(), | ||
this->slice.size() + other.slice.size(), | ||
}; | ||
return true; | ||
} | ||
|
||
//=#=#==#==#===============+=+=+=+=++=++++++++++++++-++-+--+-+----+--------------- | ||
// Explicitly specialize for MutableBuffer and ConstBuffer only. | ||
|
||
template class BasicIoRingBufferView<ConstBuffer>; | ||
template class BasicIoRingBufferView<MutableBuffer>; | ||
|
||
} //namespace llfs |
Oops, something went wrong.