Repository: vapor/vapor
File: Sources/Vapor/Application.swift (Swift)

Code before:
                    $0.insertOrReturn(.init(), at: .init(Key.self))
                }
            }
        }
    }

    public var locks: Locks {
        get {
            self._locks.withLockedValue { $0 }
        }
        set {
            self._locks.withLockedValue { $0 = newValue }
        }
    }

    public var sync: NIOLock {
        self.locks.main
    }

    public enum EventLoopGroupProvider: Sendable {
        case shared(EventLoopGroup)
        @available(*, deprecated, renamed: "singleton", message: "Use '.singleton' to use a shared EventLoopGroup for better performance, or provide your own EventLoopGroup with '.shared()'")
        case createNew

        public static var singleton: EventLoopGroupProvider {
            .shared(NIOSingletons.posixEventLoopGroup)
        }
    }

    public let eventLoopGroupProvider: EventLoopGroupProvider
    public let eventLoopGroup: EventLoopGroup
    internal let isBooted: NIOLockedValueBox<Bool>
    private let _environment: NIOLockedValueBox<Environment>
    private let _storage: NIOLockedValueBox<Storage>
    private let _didShutdown: NIOLockedValueBox<Bool>
    private let _logger: NIOLockedValueBox<Logger>
    private let _lifecycle: NIOLockedValueBox<Lifecycle>
    private let _locks: NIOLockedValueBox<Locks>

    public init(
        _ environment: Environment = .development,
        _ eventLoopGroupProvider: EventLoopGroupProvider = .shared(NIOSingletons.posixEventLoopGroup)
    ) {
        #if swift(<5.9)
            Backtrace.install()
        #endif
        self._environment = .init(environment)
        self.eventLoopGroupProvider = eventLoopGroupProvider
        switch eventLoopGroupProvider {
        case .shared(let group):
            self.eventLoopGroup = group

Review comment (suggestion):
Use `MultiThreadedEventLoopGroup.singleton` instead.

Code after:
                    $0.insertOrReturn(.init(), at: .init(Key.self))
                }
            }
        }
    }

    public var locks: Locks {
        get {
            self._locks.withLockedValue { $0 }
        }
        set {
            self._locks.withLockedValue { $0 = newValue }
        }
    }

    public var sync: NIOLock {
        self.locks.main
    }

    public enum EventLoopGroupProvider: Sendable {
        case shared(EventLoopGroup)
        @available(*, deprecated, renamed: "singleton", message: "Use '.singleton' for a shared 'EventLoopGroup', for better performance")
        case createNew

        public static var singleton: EventLoopGroupProvider {
            .shared(MultiThreadedEventLoopGroup.singleton)
        }
    }

    public let eventLoopGroupProvider: EventLoopGroupProvider
    public let eventLoopGroup: EventLoopGroup
    internal let isBooted: NIOLockedValueBox<Bool>
    private let _environment: NIOLockedValueBox<Environment>
    private let _storage: NIOLockedValueBox<Storage>
    private let _didShutdown: NIOLockedValueBox<Bool>
    private let _logger: NIOLockedValueBox<Logger>
    private let _lifecycle: NIOLockedValueBox<Lifecycle>
    private let _locks: NIOLockedValueBox<Locks>

    public init(
        _ environment: Environment = .development,
        _ eventLoopGroupProvider: EventLoopGroupProvider = .singleton
    ) {
        #if swift(<5.9)
            Backtrace.install()
        #endif
        self._environment = .init(environment)
        self.eventLoopGroupProvider = eventLoopGroupProvider
        switch eventLoopGroupProvider {
        case .shared(let group):
            self.eventLoopGroup = group