Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created January 31, 2021 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/c77a7d94fc224bad0117a62d835bd8df to your computer and use it in GitHub Desktop.
Save laevandus/c77a7d94fc224bad0117a62d835bd8df to your computer and use it in GitHub Desktop.
func read(byteRange: CountableRange<Int>, queue: DispatchQueue = .main, completionHandler: @escaping (DispatchData?) -> Void) {
if let channel = channel {
channel.read(offset: off_t(byteRange.startIndex), length: byteRange.count, queue: queue, ioHandler: { done, data, error in
print(done, data?.count ?? -1, error)
completionHandler(data)
})
}
else {
print("Channel is closed")
completionHandler(nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment