1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:17:44 +00:00

Add a DoubleBuffer thingy to allow TTY read/write to be interleaved.

I feel like this concept might be useful in more places. It's very naive
right now and uses dynamically growing buffers. It should really use static
size buffers and never kmalloc().
This commit is contained in:
Andreas Kling 2018-11-16 17:56:18 +01:00
parent 52d1822c3c
commit d2046e79cf
3 changed files with 63 additions and 12 deletions

View file

@ -188,6 +188,14 @@ public:
++m_impl->m_size;
}
void append(const T* values, size_t count)
{
ensureCapacity(size() + count);
for (size_t i = 0; i < count; ++i)
new (m_impl->slot(m_impl->m_size + i)) T(values[i]);
m_impl->m_size += count;
}
void ensureCapacity(size_t neededCapacity)
{
if (capacity() >= neededCapacity)