Skip to content

Commit

Permalink
deprecate NIOEventLoopGroupProvider (apple#2142)
Browse files Browse the repository at this point in the history
  • Loading branch information
weissi committed Jul 21, 2023
1 parent e5416f4 commit e104959
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion Sources/NIOCore/Docs.docc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ More specialized modules provide concrete implementations of many of the abstrac

- ``EventLoopGroup``
- ``EventLoop``
- ``NIOEventLoopGroupProvider``
- ``EventLoopIterator``
- ``Scheduled``
- ``RepeatedTask``
Expand Down
11 changes: 10 additions & 1 deletion Sources/NIOCore/EventLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1273,9 +1273,18 @@ extension EventLoopGroup {
}
}

/// This type is intended to be used by libraries which use NIO, and offer their users either the option
/// This type was intended to be used by libraries which use NIO, and offer their users either the option
/// to `.share` an existing event loop group or create (and manage) a new one (`.createNew`) and let it be
/// managed by given library and its lifecycle.
@available(*, deprecated,
message: """
Please use a `group: any EventLoopGroup` parameter instead. If you want to default to a global
singleton group instead, consider
`group: any EventLoopGroup = MultiThreadedEventLoopGroup.globalSingleton` or
similar. Having the option to `.createNew`
EventLoopGroups causes more issues than it solves.
See also: https://github.com/apple/swift-nio/issues/2142
""")
public enum NIOEventLoopGroupProvider {
/// Use an `EventLoopGroup` provided by the user.
/// The owner of this group is responsible for its lifecycle.
Expand Down
1 change: 1 addition & 0 deletions Tests/NIOPosixTests/EventLoopTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,7 @@ public final class EventLoopTest : XCTestCase {
waiter.wait()
}

@available(*, deprecated)
func testEventLoopGroupProvider() {
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer {
Expand Down

0 comments on commit e104959

Please sign in to comment.