Skip to content

Commit

Permalink
Use a blocking queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr. Brandon Wiley committed Nov 19, 2021
1 parent 776ff71 commit 1296d02
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Sources/TransmissionLinux/TransmissionConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class TransmissionConnection: Connection
var readLock = DispatchGroup()
var writeLock = DispatchGroup()
let log: Logger?
let states: Queue<Bool> = Queue<Bool>()
let states: BlockingQueue<Bool> = BlockingQueue<Bool>()

var buffer: Data = Data()

Expand Down Expand Up @@ -57,7 +57,7 @@ public class TransmissionConnection: Connection
mutableTransport.stateUpdateHandler = self.handleState
mutableTransport.start(queue: .global())

guard let success = self.states.dequeue() else {return nil}
let success = self.states.dequeue()
guard success else {return nil}
}

Expand All @@ -75,18 +75,18 @@ public class TransmissionConnection: Connection
switch state
{
case .ready:
self.states.enqueue(true)
self.states.enqueue(element: true)
return
case .cancelled:
self.states.enqueue(false)
self.states.enqueue(element: false)
self.failConnect()
return
case .failed(_):
self.states.enqueue(false)
self.states.enqueue(element: false)
self.failConnect()
return
case .waiting(_):
self.states.enqueue(false)
self.states.enqueue(element: false)
self.failConnect()
return
default:
Expand Down

0 comments on commit 1296d02

Please sign in to comment.