Skip to content

Commit aa71c66

Browse files
committed
⚡ (LogKit): Process fifo by chuncks of 64 bytes
1 parent d14d36b commit aa71c66

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

libs/LogKit/include/LogKit.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ namespace buffer {
3737
inline auto message = std::array<char, 256> {};
3838
inline auto output = std::array<char, 512> {};
3939

40-
inline auto fifo = CircularQueue<char, 4096> {};
40+
inline auto fifo = CircularQueue<char, 4096> {};
41+
static auto process_buffer = std::array<char, 64> {};
4142

4243
}; // namespace buffer
4344

@@ -104,9 +105,8 @@ namespace internal {
104105
inline void process_fifo()
105106
{
106107
while (!buffer::fifo.empty()) {
107-
auto c = char {};
108-
buffer::fifo.pop(c);
109-
internal::filehandle->write(&c, 1);
108+
auto length = buffer::fifo.pop(buffer::process_buffer.data(), std::size(buffer::process_buffer));
109+
internal::filehandle->write(buffer::process_buffer.data(), length);
110110
}
111111
}
112112

libs/LogKit/tests/LogKit_test_fifo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,21 @@ TEST_F(LogKitFifoTest, processEmpty)
5050

5151
TEST_F(LogKitFifoTest, processNotEmpty)
5252
{
53-
EXPECT_CALL(mockfh, write).Times(128);
53+
EXPECT_CALL(mockfh, write).Times(128 / std::size(logger::buffer::process_buffer));
5454

5555
for (auto i = 0; i < 128; ++i) {
56-
logger::buffer::fifo.push(i);
56+
logger::buffer::fifo.push(static_cast<char>(i));
5757
}
5858

5959
logger::process_fifo();
6060
}
6161

6262
TEST_F(LogKitFifoTest, processFull)
6363
{
64-
EXPECT_CALL(mockfh, write).Times(4096);
64+
EXPECT_CALL(mockfh, write).Times(4096 / std::size(logger::buffer::process_buffer));
6565

6666
for (auto i = 0; i < 4096; ++i) {
67-
logger::buffer::fifo.push(i);
67+
logger::buffer::fifo.push(static_cast<char>(i));
6868
}
6969

7070
logger::process_fifo();

0 commit comments

Comments
 (0)