File tree Expand file tree Collapse file tree 6 files changed +39
-32
lines changed Expand file tree Collapse file tree 6 files changed +39
-32
lines changed Original file line number Diff line number Diff line change 1
1
// Copyright (c) Stefano Cristiano
2
2
// SPDX-License-Identifier: MIT
3
- #include " ../Containers/Internal/IntrusiveDoubleLinkedList.inl"
3
+ #include " ../Containers/Internal/IntrusiveDoubleLinkedList.inl" // IWYU pragma: keep
4
4
#include " ../Foundation/Platform.h"
5
- #include " ../Socket/Socket.h"
6
5
7
6
#include < string.h> // strncpy
8
7
Original file line number Diff line number Diff line change @@ -13,6 +13,31 @@ struct SC::AsyncEventLoop::Internal
13
13
struct KernelEventsIoURing ;
14
14
struct KernelQueue ;
15
15
struct KernelEvents ;
16
+
17
+ struct KernelQueue
18
+ {
19
+ AlignedStorage<320 > storage;
20
+
21
+ bool isEpoll = true ;
22
+
23
+ KernelQueue ();
24
+ ~KernelQueue ();
25
+ KernelQueueIoURing& getUring ();
26
+ KernelQueuePosix& getPosix ();
27
+
28
+ // On io_uring it doesn't make sense to run operations in a thread pool
29
+ [[nodiscard]] bool makesSenseToRunInThreadPool (AsyncRequest&) { return isEpoll; }
30
+
31
+ Result close ();
32
+ Result createEventLoop (AsyncEventLoop::Options options);
33
+ Result createSharedWatchers (AsyncEventLoop&);
34
+ Result wakeUpFromExternalThread ();
35
+
36
+ static Result associateExternallyCreatedSocket (SocketDescriptor&) { return Result (true ); }
37
+ static Result associateExternallyCreatedFileDescriptor (FileDescriptor&) { return Result (true ); }
38
+ static Result removeAllAssociationsFor (SocketDescriptor&) { return Result (true ); }
39
+ static Result removeAllAssociationsFor (FileDescriptor&) { return Result (true ); }
40
+ };
16
41
#elif SC_PLATFORM_APPLE
17
42
struct KernelQueuePosix ;
18
43
struct KernelEventsPosix ;
Original file line number Diff line number Diff line change 9
9
#include < sys/syscall.h> // SYS_pidfd_open
10
10
#include < sys/wait.h> // waitpid
11
11
12
- struct SC ::AsyncEventLoop::Internal::KernelQueue
13
- {
14
- AlignedStorage<320 > storage;
15
-
16
- bool isEpoll = true ;
17
-
18
- KernelQueue ();
19
- ~KernelQueue ();
20
- KernelQueueIoURing& getUring ();
21
- KernelQueuePosix& getPosix ();
22
-
23
- // On io_uring it doesn't make sense to run operations in a thread pool
24
- [[nodiscard]] bool makesSenseToRunInThreadPool (AsyncRequest&) { return isEpoll; }
25
-
26
- Result close ();
27
- Result createEventLoop (AsyncEventLoop::Options options);
28
- Result createSharedWatchers (AsyncEventLoop&);
29
- Result wakeUpFromExternalThread ();
30
-
31
- static Result associateExternallyCreatedSocket (SocketDescriptor&) { return Result (true ); }
32
- static Result associateExternallyCreatedFileDescriptor (FileDescriptor&) { return Result (true ); }
33
- static Result removeAllAssociationsFor (SocketDescriptor&) { return Result (true ); }
34
- static Result removeAllAssociationsFor (FileDescriptor&) { return Result (true ); }
35
- };
36
-
37
12
struct SC ::AsyncEventLoop::Internal::KernelEvents
38
13
{
39
14
bool isEpoll = true ;
@@ -73,7 +48,6 @@ struct SC::AsyncEventLoop::Internal::KernelEvents
73
48
// clang-format on
74
49
};
75
50
76
- #define SC_ASYNC_USE_EPOLL 1 // uses epoll
77
51
#include " AsyncPosix.inl"
78
52
79
53
#include " AsyncLinuxAPI.h"
Original file line number Diff line number Diff line change 1
1
#include < dlfcn.h>
2
+ #include < stdint.h>
3
+ #include < string.h>
4
+ #include < sys/uio.h> // for iovec
5
+ #include < unistd.h>
2
6
3
7
struct AsyncLinuxAPI
4
8
{
@@ -148,7 +152,6 @@ struct AsyncLinuxLibURingLoader : public AsyncLinuxAPI
148
152
//
149
153
// TODO: Use the liburing-ffi supplied functions if they're available on the system
150
154
151
- #include < errno.h> // errno
152
155
#include < linux/io_uring.h> // io_uring
153
156
#include < linux/time_types.h> // __kernel_timespec
154
157
Original file line number Diff line number Diff line change 1
1
// Copyright (c) Stefano Cristiano
2
2
// SPDX-License-Identifier: MIT
3
-
4
3
#include " AsyncInternal.h"
5
4
5
+ #include " ../../Foundation/Assert.h"
6
6
#include " ../../Foundation/Deferred.h"
7
+ #include " ../../Socket/Socket.h"
8
+
9
+ #if SC_PLATFORM_LINUX
10
+ #define SC_ASYNC_USE_EPOLL 1 // uses epoll
11
+ #endif
7
12
8
13
#if SC_ASYNC_USE_EPOLL
9
14
15
20
#include < sys/socket.h> // For socket-related functions
16
21
#include < sys/stat.h> // fstat
17
22
#include < sys/uio.h> // writev, pwritev
23
+ #include < sys/wait.h> // waitpid / WIFEXITED / WEXITSTATUS
18
24
19
25
#else
20
26
@@ -189,8 +195,7 @@ struct SC::AsyncEventLoop::Internal::KernelQueuePosix
189
195
struct signalfd_siginfo siginfo;
190
196
FileDescriptor::Handle sigHandle;
191
197
192
- const KernelQueuePosix& kernelQueue = result.eventLoop .internal .kernelQueue .get ().getPosix ();
193
- Result res = kernelQueue.signalProcessExitDescriptor .get (sigHandle, Result::Error (" Invalid signal handle" ));
198
+ Result res = signalProcessExitDescriptor.get (sigHandle, Result::Error (" Invalid signal handle" ));
194
199
if (not res)
195
200
{
196
201
return ;
Original file line number Diff line number Diff line change 8
8
#include < Ws2tcpip.h> // sockadd_in6
9
9
10
10
#include " ../../Foundation/Deferred.h"
11
+ #include " ../../Socket/Socket.h"
11
12
#include " AsyncInternal.h"
12
13
#include " AsyncWindows.h"
13
14
#include " AsyncWindowsAPI.h"
You can’t perform that action at this time.
0 commit comments