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

Code before:
    @available(*, noasync, message: "This can potentially block the thread and should not be called in an async context", renamed: "asyncBoot()")
    /// Called when the applications starts up, will trigger the lifecycle handlers
    public func boot() throws {
        try self.isBooted.withLockedValue { booted in
            guard !booted else {
                return
            }
            booted = true
            try self.lifecycle.handlers.forEach { try $0.willBoot(self) }
            try self.lifecycle.handlers.forEach { try $0.didBoot(self) }
        }
    }
    
    /// Called when the applications starts up, will trigger the lifecycle handlers. The asynchronous version of ``boot()``
    public func asyncBoot() async throws {
        let notBooted = self.isBooted.withLockedValue { booted in
            guard booted else {
                booted = true
                return true
            }

            return false
        }

        guard notBooted else { return }

        for handler in self.lifecycle.handlers {
            try await handler.willBootAsync(self)
        }
        for handler in self.lifecycle.handlers {
            try await handler.didBootAsync(self)
        }
    }

    @available(*, noasync, message: "This can block the thread and should not be called in an async context", renamed: "asyncShutdown()")
    public func shutdown() {
        assert(!self.didShutdown, "Application has already shut down")
        self.logger.debug("Application shutting down")

        self.logger.trace("Shutting down providers")
        self.lifecycle.handlers.reversed().forEach { $0.shutdown(self) }
        
        triggerShutdown()

        switch self.eventLoopGroupProvider {
        case .shared:
            self.logger.trace("Running on shared EventLoopGroup. Not shutting down EventLoopGroup.")
        case .createNew:
            self.logger.trace("Shutting down EventLoopGroup")
            do {
                try self.eventLoopGroup.syncShutdownGracefully()

Review comment (suggestion):
```suggestion
        guard !self.isBooted.withLockedValue({
            var result = true
            swap(&$0, &result)
            return result
        }) else {
            return
        }

Code after:
    @available(*, noasync, message: "This can potentially block the thread and should not be called in an async context", renamed: "asyncBoot()")
    /// Called when the applications starts up, will trigger the lifecycle handlers
    public func boot() throws {
        try self.isBooted.withLockedValue { booted in
            guard !booted else {
                return
            }
            booted = true
            try self.lifecycle.handlers.forEach { try $0.willBoot(self) }
            try self.lifecycle.handlers.forEach { try $0.didBoot(self) }
        }
    }
    
    /// Called when the applications starts up, will trigger the lifecycle handlers. The asynchronous version of ``boot()``
    public func asyncBoot() async throws {
        /// Skip the boot process if already booted
        guard !self.isBooted.withLockedValue({
            var result = true
            swap(&$0, &result)
            return result
        }) else {
            return
        }

        for handler in self.lifecycle.handlers {
            try await handler.willBootAsync(self)
        }
        for handler in self.lifecycle.handlers {
            try await handler.didBootAsync(self)
        }
    }

    @available(*, noasync, message: "This can block the thread and should not be called in an async context", renamed: "asyncShutdown()")
    public func shutdown() {
        assert(!self.didShutdown, "Application has already shut down")
        self.logger.debug("Application shutting down")

        self.logger.trace("Shutting down providers")
        self.lifecycle.handlers.reversed().forEach { $0.shutdown(self) }
        
        triggerShutdown()

        switch self.eventLoopGroupProvider {
        case .shared:
            self.logger.trace("Running on shared EventLoopGroup. Not shutting down EventLoopGroup.")
        case .createNew:
            self.logger.trace("Shutting down EventLoopGroup")
            do {
                try self.eventLoopGroup.syncShutdownGracefully()
            } catch {
                self.logger.warning("Shutting down EventLoopGroup failed: \(error)")