LibIPC: Allow transporting a SharedCircularQueue over IPC
This commit is contained in:
parent
6b13436ef6
commit
fc7d231b00
Notes:
sideshowbarker
2024-07-17 20:22:04 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/fc7d231b00 Pull-request: https://github.com/SerenityOS/serenity/pull/12102 Issue: https://github.com/SerenityOS/serenity/issues/11882 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/bgianfo Reviewed-by: https://github.com/linusg
2 changed files with 23 additions and 0 deletions
|
@ -11,7 +11,10 @@
|
|||
#include <AK/NumericLimits.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Try.h>
|
||||
#include <LibCore/SharedCircularQueue.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibIPC/File.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
#include <LibIPC/Message.h>
|
||||
|
||||
|
@ -117,6 +120,18 @@ public:
|
|||
return {};
|
||||
}
|
||||
|
||||
template<typename T, size_t Size>
|
||||
ErrorOr<void> decode(Core::SharedSingleProducerCircularQueue<T, Size>& queue)
|
||||
{
|
||||
// FIXME: We don't support decoding into valid queues.
|
||||
VERIFY(!queue.is_valid());
|
||||
|
||||
IPC::File anon_file;
|
||||
TRY(decode(anon_file));
|
||||
queue = TRY((Core::SharedSingleProducerCircularQueue<T, Size>::try_create(anon_file.take_fd())));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ErrorOr<void> decode(Optional<T>& optional)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/Concepts.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <LibCore/SharedCircularQueue.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
#include <LibIPC/Message.h>
|
||||
|
||||
|
@ -77,6 +78,13 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename T, size_t Size>
|
||||
Encoder& operator<<(Core::SharedSingleProducerCircularQueue<T, Size> const& queue)
|
||||
{
|
||||
*this << IPC::File(queue.fd());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<Enum T>
|
||||
Encoder& operator<<(T const& enum_value)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue