diff --git a/NvimView/NvimView/NvimView.swift b/NvimView/NvimView/NvimView.swift index 6f5023b1..5b746446 100644 --- a/NvimView/NvimView/NvimView.swift +++ b/NvimView/NvimView/NvimView.swift @@ -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() diff --git a/NvimView/NvimView/UiBridge.swift b/NvimView/NvimView/UiBridge.swift index 15270cb6..c8ef0059 100644 --- a/NvimView/NvimView/UiBridge.swift +++ b/NvimView/NvimView/UiBridge.swift @@ -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() diff --git a/RxPack/RxMessagePort.swift b/RxPack/RxMessagePort.swift index d7e8f6ac..7992d6dd 100644 --- a/RxPack/RxMessagePort.swift +++ b/RxPack/RxMessagePort.swift @@ -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 { 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() diff --git a/RxPack/RxMsgpackRpc.swift b/RxPack/RxMsgpackRpc.swift index 813b87a2..068b0ee3 100644 --- a/RxPack/RxMsgpackRpc.swift +++ b/RxPack/RxMsgpackRpc.swift @@ -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() diff --git a/RxPack/RxNeovimApi.swift b/RxPack/RxNeovimApi.swift index f3bda1fd..58977d9b 100644 --- a/RxPack/RxNeovimApi.swift +++ b/RxPack/RxNeovimApi.swift @@ -54,15 +54,6 @@ public final class RxNeovimApi { public var msgpackRawStream: Observable { 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 {