Skip to content

Commit

Permalink
LibIPC: Implement IPC::{en,de}code for SharedSingleProducerCircularQueue
Browse files Browse the repository at this point in the history
on Windows
  • Loading branch information
stasoid committed Dec 7, 2024
1 parent e56435a commit 70a8093
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Libraries/LibIPC/Decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,13 @@ ErrorOr<T> decode(Decoder& decoder)
template<Concepts::SharedSingleProducerCircularQueue T>
ErrorOr<T> decode(Decoder& decoder)
{
#ifndef AK_OS_WINDOWS
auto anon_file = TRY(decoder.decode<IPC::File>());
return T::create(anon_file.take_fd());
#else
auto handle = TRY(decoder.decode<intptr_t>());
return T::create((int)handle);
#endif
}

template<Concepts::Optional T>
Expand Down
4 changes: 4 additions & 0 deletions Libraries/LibIPC/Encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ ErrorOr<void> encode(Encoder& encoder, T const& hashmap)
template<Concepts::SharedSingleProducerCircularQueue T>
ErrorOr<void> encode(Encoder& encoder, T const& queue)
{
#ifndef AK_OS_WINDOWS
TRY(encoder.encode(TRY(IPC::File::clone_fd(queue.fd()))));
#else
TRY(encoder.encode((intptr_t)queue.fd()));
#endif
return {};
}

Expand Down

0 comments on commit 70a8093

Please sign in to comment.