1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-28 02:54:31 +03:00

Make queues private

This commit is contained in:
Tae Won Ha 2020-01-26 20:31:10 +01:00
parent a7a34c610d
commit b8216973b0
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
5 changed files with 42 additions and 47 deletions

View File

@ -65,17 +65,17 @@ public class NvimView: NSView,
self.updateFontMetaData(self._font)
}
}
public var characterspacing: CGFloat {
get {
return self._characterspacing
}
set {
guard newValue >= 0.0 else {
return
}
self._characterspacing = newValue
self.updateFontMetaData(self._font)
}
@ -121,10 +121,6 @@ public class NvimView: NSView,
return true
}
public let queue = DispatchQueue(
label: String(reflecting: NvimView.self),
qos: .userInteractive
)
public let scheduler: SerialDispatchQueueScheduler
public internal(set) var currentPosition = Position.beginning
@ -140,9 +136,11 @@ public class NvimView: NSView,
characterspacing: self._characterspacing,
usesLigatures: self.usesLigatures
)
self.bridge = UiBridge(uuid: self.uuid, queue: self.queue, config: config)
self.scheduler = SerialDispatchQueueScheduler(queue: self.queue,
internalSerialQueueName: "com.qvacua.NvimView.NvimView")
self.bridge = UiBridge(uuid: self.uuid, config: config)
self.scheduler = SerialDispatchQueueScheduler(
queue: self.queue,
internalSerialQueueName: "com.qvacua.NvimView.NvimView"
)
self.sourceFileUrls = config.sourceFiles
@ -154,8 +152,6 @@ public class NvimView: NSView,
self.cellSize = FontUtils.cellSize(
of: self.font, linespacing: self.linespacing, characterspacing: self.characterspacing
)
self.api.queue = self.queue
}
convenience override public init(frame rect: NSRect) {
@ -182,6 +178,11 @@ public class NvimView: NSView,
}
// MARK: - Internal
let queue = DispatchQueue(
label: String(reflecting: NvimView.self),
qos: .userInteractive
)
let bridge: UiBridge
let api = RxNeovimApi()

View File

@ -41,7 +41,7 @@ class UiBridge {
weak var consumer: UiBridgeConsumer?
init(uuid: UUID, queue: DispatchQueue, config: NvimView.Config) {
init(uuid: UUID, config: NvimView.Config) {
self.uuid = uuid
self.useInteractiveZsh = config.useInteractiveZsh
@ -60,11 +60,10 @@ class UiBridge {
self.log.debug("Using ENVs from login shell: \(self.envDict)")
}
self.queue = queue
self.scheduler = SerialDispatchQueueScheduler(queue: queue,
internalSerialQueueName: String(reflecting: UiBridge.self))
self.client.queue = self.queue
self.server.queue = self.queue
self.scheduler = SerialDispatchQueueScheduler(
queue: queue,
internalSerialQueueName: String(reflecting: UiBridge.self)
)
self.server.stream
.subscribe(onNext: { [weak self] message in
@ -334,7 +333,10 @@ class UiBridge {
private var runLocalServerAndNvimCompletable: Completable.CompletableObserver?
private let scheduler: SerialDispatchQueueScheduler
private let queue: DispatchQueue
private let queue = DispatchQueue(
label: String(reflecting: UiBridge.self),
qos: .userInitiated
)
private let disposeBag = DisposeBag()

View File

@ -31,13 +31,6 @@ public final class RxMessagePortClient {
public var timeout = RxMessagePortClient.defaultTimeout
public var queue = DispatchQueue(
label: String(reflecting: RxMessagePortClient.self),
qos: .userInitiated
)
public init() {}
public func send(
msgid: Int32,
data: Data?,
@ -121,6 +114,11 @@ public final class RxMessagePortClient {
private var portIsValid = false
private var port: CFMessagePort?
private let queue = DispatchQueue(
label: String(reflecting: RxMessagePortClient.self),
qos: .userInitiated
)
}
public final class RxMessagePortServer {
@ -140,11 +138,6 @@ public final class RxMessagePortServer {
public var stream: Observable<Message> { self.streamSubject.asObservable() }
public var queue = DispatchQueue(
label: String(reflecting: RxMessagePortServer.self),
qos: .userInitiated
)
public init() { self.messageHandler = MessageHandler(subject: self.streamSubject) }
public func run(as name: String) -> Completable {
@ -210,6 +203,11 @@ public final class RxMessagePortServer {
private var portThread: Thread?
private var portRunLoop: CFRunLoop?
private let queue = DispatchQueue(
label: String(reflecting: RxMessagePortClient.self),
qos: .userInitiated
)
private var messageHandler: MessageHandler
private let streamSubject = PublishSubject<Message>()

View File

@ -58,16 +58,9 @@ public final class RxMsgpackRpc {
*/
public var streamResponses = false
public var queue = DispatchQueue(
label: String(reflecting: RxMsgpackRpc.self),
qos: .userInitiated
)
private var socket: Socket?
private var thread: Thread?
public init() {}
public func run(at path: String) -> Completable {
Completable.create { completable in
self.queue.async {
@ -187,6 +180,11 @@ public final class RxMsgpackRpc {
private var nextMsgid: UInt32 = 0
private let nextMsgidLock = NSLock()
private let queue = DispatchQueue(
label: String(reflecting: RxMsgpackRpc.self),
qos: .userInitiated
)
private var stopped = true
private let stopLock = ReadersWriterLock()

View File

@ -54,15 +54,6 @@ public final class RxNeovimApi {
public var msgpackRawStream: Observable<RxMsgpackRpc.Message> { self.msgpackRpc.stream }
public var queue = DispatchQueue(
label: String(reflecting: RxNeovimApi.self),
qos: .userInitiated
) {
didSet { self.msgpackRpc.queue = self.queue }
}
public init() { self.msgpackRpc.queue = self.queue }
public func run(at path: String) -> Completable { self.msgpackRpc.run(at: path) }
public func stop() -> Completable { self.msgpackRpc.stop() }
@ -94,6 +85,11 @@ public final class RxNeovimApi {
}
private let msgpackRpc = RxMsgpackRpc()
private let queue = DispatchQueue(
label: String(reflecting: RxNeovimApi.self),
qos: .userInitiated
)
}
fileprivate extension NSLocking {