Skip to content

Conversation

@scottmarchant
Copy link
Collaborator

@scottmarchant scottmarchant commented Dec 2, 2025

Summary

Implements AsyncEventLoop and MultiThreadedEventLoopGroup atop AsyncEventLoopExecutor for non-Posix runtimes.

Details

  • 023e473 feat: Implement AsynceEventLoop and MultiThreadedEventLoopGroup using Swift Concurrency and the AsyncEventLoopExecutor. Forms a key foundation for several vapor repositories to use NIO without using NIOPosix. This enables a large amount of wasm compilation for packages that currently consume NIOPosix.

Usage Examples

  • Schedule work on a manual-time async event loop and advance time deterministically:
let loop = AsyncEventLoop()
let scheduled = loop.scheduleTask(in: .seconds(1)) { "done" }
// Wait more than one second…
let value = try await scheduled.futureResult.get()  // "done"
  • Run tasks on a MultiThreadedEventLoopGroup:
let group = MultiThreadedEventLoopGroup(numberOfThreads: 2)
let loop = group.next()
let future: EventLoopFuture<String> = loop.submit { "hello" }
let value = try await future.get() // "hello"
try await group.shutdownGracefully()

Testing Performed

Tests coverage provided in tests ported from NIOPosix: #6, #7, #10.

The changes have also been tested in real-world application by running GraphManager and QuantumProjectManager in the browser to migrate database schemas, connect with our server, and pull data from a real user account.

PR Dependencies

#11

Overview of all changes

All planned changes can be viewed together in #2

@scottmarchant scottmarchant changed the title Implement AsyncEventLoop and MultiThreadedEventLoopGroup feat: Implement AsyncEventLoop and MultiThreadedEventLoopGroup Dec 2, 2025
@scottmarchant scottmarchant force-pushed the build/setUpInitialPackageAndCI branch from d7f5ff7 to 5f6892f Compare December 2, 2025 17:54
@scottmarchant scottmarchant force-pushed the feat/implementAsyncEventLoopAndMultiThreadedEventLoopGroup branch from 023e473 to 033ecf7 Compare December 2, 2025 18:24
@scottmarchant scottmarchant changed the base branch from build/setUpInitialPackageAndCI to feat/implementAsyncEventLoopExecutor December 2, 2025 20:04
@scottmarchant scottmarchant self-assigned this Dec 2, 2025
@scottmarchant scottmarchant marked this pull request as ready for review December 2, 2025 20:20
@scottmarchant scottmarchant force-pushed the feat/implementAsyncEventLoopExecutor branch from 2eca931 to a0368a0 Compare December 3, 2025 20:17
@scottmarchant scottmarchant force-pushed the feat/implementAsyncEventLoopAndMultiThreadedEventLoopGroup branch from 033ecf7 to 884df89 Compare December 3, 2025 20:21
Base automatically changed from feat/implementAsyncEventLoopExecutor to main December 3, 2025 20:44
… Swift Concurrency and the AsyncEventLoopExecutor. Forms a key foundation for several vapor repositories to use NIO without using NIOPosix. This enables a large amount of wasm compilation for packages that currently consume NIOPosix.
@scottmarchant scottmarchant force-pushed the feat/implementAsyncEventLoopAndMultiThreadedEventLoopGroup branch from 884df89 to 8dce0c8 Compare December 3, 2025 20:44
@scottmarchant scottmarchant merged commit 9850f2f into main Dec 5, 2025
23 checks passed
@scottmarchant scottmarchant deleted the feat/implementAsyncEventLoopAndMultiThreadedEventLoopGroup branch December 5, 2025 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants