Closed dsperling closed 8 years ago
@dsperling Thanks for your continued interest in Kitura-redis.
A couple of questions:
@shmuelk Comments:
@dsperling I understand things better now. I even remember why I added that queue in the test code.
I would prefer at this time to not remove Kitura-sys as a dependency. The goal is once libdispatch on Linux gets the same nice object oriented overlay that GCD has on Darwin, to start removing our dependency on Kitura-sys. At this time please have an appropriate minor in the dependency. Also update the README.md as appropriate.
@shmuelk
I looked into what it would take to remove Kitura-sys. If the following code was added to TestListPart3.swift we could remove Kitura-sys now. Let me know which direction you want to take and will update the PR later today.
import Dispatch
public class Queue {
internal let osQueue: dispatch_queue_t
public init(label: String?=nil) {
osQueue = dispatch_queue_create(label != nil ? label! : "",
DISPATCH_QUEUE_CONCURRENT)
}
public func enqueueAsynchronously(_ block: () -> Void) {
dispatch_async(osQueue, block)
}
}
+1 to removing this dependency on Kitura-sys as it seems minimal extra code. Plus once the new Swift 3 GCD overlay is available we can even remove that.
@shmuelk I made the changes you requested using @discardableResult and reverted all the changes previously made in the unit tests. I also moved the Queue class, removing all Kitura-sys dependencies. To make the transition simpler when the DispatchQueue class becomes available, I aligned the Queue API to match DispatchQueue.
@dsperling The problem I have with in-lining the queue class is that when we migrate to the 06/20 drop of Swift, Darwin gets the new GCD overlay while Linux doesn't. I'd rather have to deal with that in only one place rather than in many.
Maybe we should wait until the new GCD overlay is available on Linux, before moving up snapshots.
Sounds good. I will keep this PR open and keep it updated for future snapshots.
Personally I think we should merge it now, but it's @shmuelk 's decision 😄
@dsperling I really like this PR. You really have done good things here. I don't like the idea of keeping the PR open until we can replace the usage here of Kitura-sys with a better overlay for Dispatch on Linux. I have no idea how long that will take and it will be a shame to keep this PR up to date just for that.
I'm going to merge it and that add back the dependency on Kitura-sys and remove your added queueing code and use the code from Kitura-sys. There are also now merge conflicts, apparently due to the other PR that I just merged. I'll take care of those as well.
Description
This improves the readability of fix #13 as well as removes the dependency of Kitura-sys. Note, Kitura-sys is still required for the unit tests and therefore remains in Package.swift. Since only the unit tests now use Kitura-sys, I removed the requirement of matching the minor version (which should help Kitura-redis be more forwards compatible).
Motivation and Context
The following changes were made:
RedisString("...").asData
as the main function to create a safe NSData from a string.?? NSData()
fix for Linux to RedisMisc.swiftmajorVersion: 0
How Has This Been Tested?
Unit tested on Mac and Linux
Checklist: