Skip to content

Commit bb8e2b2

Browse files
committed
Position nested types and initializers on top
1 parent 57ad7ad commit bb8e2b2

File tree

4 files changed

+41
-41
lines changed

4 files changed

+41
-41
lines changed

vminitd/Sources/vminitd/ManagedProcess.swift

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,16 @@ import Logging
2525
import Synchronization
2626

2727
final class ManagedProcess: Sendable {
28-
let id: String
29-
30-
private let log: Logger
31-
private let process: Command
32-
private let state: Mutex<State>
33-
private let owningPid: Int32?
34-
private let ackPipe: Pipe
35-
private let syncPipe: Pipe
36-
private let terminal: Bool
37-
private let bundle: ContainerizationOCI.Bundle
38-
private let cgroupManager: Cgroup2Manager?
28+
// swiftlint: disable type_name
29+
protocol IO {
30+
func attach(pid: Int32, fd: Int32) throws
31+
func start(process: inout Command) throws
32+
func resize(size: Terminal.Size) throws
33+
func close() throws
34+
func closeStdin() throws
35+
func closeAfterExec() throws
36+
}
37+
// swiftlint: enable type_name
3938

4039
struct ExitStatus {
4140
var exitStatus: Int32
@@ -53,26 +52,27 @@ final class ManagedProcess: Sendable {
5352
var pid: Int32 = 0
5453
}
5554

55+
private static let ackPid = "AckPid"
56+
private static let ackConsole = "AckConsole"
57+
58+
let id: String
59+
60+
private let log: Logger
61+
private let process: Command
62+
private let state: Mutex<State>
63+
private let owningPid: Int32?
64+
private let ackPipe: Pipe
65+
private let syncPipe: Pipe
66+
private let terminal: Bool
67+
private let bundle: ContainerizationOCI.Bundle
68+
private let cgroupManager: Cgroup2Manager?
69+
5670
var pid: Int32 {
5771
self.state.withLock {
5872
$0.pid
5973
}
6074
}
6175

62-
// swiftlint: disable type_name
63-
protocol IO {
64-
func attach(pid: Int32, fd: Int32) throws
65-
func start(process: inout Command) throws
66-
func resize(size: Terminal.Size) throws
67-
func close() throws
68-
func closeStdin() throws
69-
func closeAfterExec() throws
70-
}
71-
// swiftlint: enable type_name
72-
73-
private static let ackPid = "AckPid"
74-
private static let ackConsole = "AckConsole"
75-
7676
init(
7777
id: String,
7878
stdio: HostStdio,

vminitd/Sources/vminitd/OSFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import Foundation
1818

1919
struct OSFile: Sendable {
20-
private let fd: Int32
21-
2220
enum IOAction: Equatable {
2321
case eof
2422
case again
@@ -27,6 +25,8 @@ struct OSFile: Sendable {
2725
case error(_ errno: Int32)
2826
}
2927

28+
private let fd: Int32
29+
3030
var closed: Bool {
3131
Foundation.fcntl(fd, F_GETFD) == -1 && errno == EBADF
3232
}

vminitd/Sources/vminitd/Server.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ import NIOCore
2222
import NIOPosix
2323

2424
final class Initd: Sendable {
25-
let log: Logger
26-
let state: State
27-
let group: EventLoopGroup
28-
2925
actor State {
3026
var containers: [String: ManagedContainer] = [:]
3127
var proxies: [String: VsockProxy] = [:]
@@ -80,6 +76,10 @@ final class Initd: Sendable {
8076
}
8177
}
8278

79+
let log: Logger
80+
let state: State
81+
let group: EventLoopGroup
82+
8383
init(log: Logger, group: EventLoopGroup) {
8484
self.log = log
8585
self.group = group

vminitd/Sources/vminitd/VsockProxy.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ actor VsockProxy {
3030
case vsock
3131
}
3232

33+
public let id: String
34+
private let path: URL
35+
private let action: Action
36+
private let port: UInt32
37+
private let udsPerms: UInt32?
38+
private let log: Logger?
39+
40+
private var listener: Socket?
41+
private var task: Task<(), Never>?
42+
3343
init(
3444
id: String,
3545
action: Action,
@@ -45,16 +55,6 @@ actor VsockProxy {
4555
self.udsPerms = udsPerms
4656
self.log = log
4757
}
48-
49-
public let id: String
50-
private let path: URL
51-
private let action: Action
52-
private let port: UInt32
53-
private let udsPerms: UInt32?
54-
private let log: Logger?
55-
56-
private var listener: Socket?
57-
private var task: Task<(), Never>?
5858
}
5959

6060
extension VsockProxy {

0 commit comments

Comments
 (0)