Skip to content

Commit

Permalink
Merge pull request #6 from IBM-DTeam/queue
Browse files Browse the repository at this point in the history
Resolves #5
  • Loading branch information
GWlodarek authored Jul 28, 2016
2 parents 64df9a1 + f60f736 commit 5d3cbd7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
28 changes: 19 additions & 9 deletions Sources/IBMDB/SwiftDB2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,22 @@ import Darwin
import IBMCliDarwin
#endif

// Custom named queues
#if os(Linux)
let queue = dispatch_queue_create("swift-for-db2", DISPATCH_QUEUE_CONCURRENT)
#else
let queue = DispatchQueue(label: "swift-for-db2", attributes: .concurrent)
#endif


/**
* IBMDB Class
*
* Allows the user to connect to a database.
*/
public class IBMDB {


/**
* Empty constructor to initialize IBMDB.
*/
Expand Down Expand Up @@ -80,11 +89,11 @@ public class IBMDB {
}

#if os(Linux)
dispatch_async(dispatch_get_global_queue(Int(DISPATCH_QUEUE_PRIORITY_HIGH), 0), {
dispatch_async(queue) {
run()
})
}
#else
DispatchQueue.main.async {
queue.sync {
run()
}
#endif
Expand Down Expand Up @@ -194,11 +203,11 @@ public class Connection {
}

#if os(Linux)
dispatch_async(dispatch_get_global_queue(Int(DISPATCH_QUEUE_PRIORITY_HIGH), 0), {
dispatch_async(queue) {
run()
})
}
#else
DispatchQueue.main.async {
queue.sync {
run()
}
#endif
Expand Down Expand Up @@ -344,14 +353,15 @@ public class Connection {
}

#if os(Linux)
dispatch_async(dispatch_get_global_queue(Int(DISPATCH_QUEUE_PRIORITY_HIGH), 0), {
dispatch_async(queue) {
run()
})
}
#else
DispatchQueue.main.async {
queue.sync {
run()
}
#endif

}


Expand Down
4 changes: 2 additions & 2 deletions Tests/IBMDB/ConnectTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ConnectTests : XCTestCase {
expectation.fulfill()
}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand All @@ -76,7 +76,7 @@ class ConnectTests : XCTestCase {
expectation.fulfill()
}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/IBMDB/DisconnectTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class DisconnectTests : XCTestCase {
expectation.fulfill()
}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down
24 changes: 12 additions & 12 deletions Tests/IBMDB/QueryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class QueryTests : XCTestCase {

}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down Expand Up @@ -193,7 +193,7 @@ class QueryTests : XCTestCase {

}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down Expand Up @@ -252,7 +252,7 @@ class QueryTests : XCTestCase {

}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down Expand Up @@ -295,7 +295,7 @@ class QueryTests : XCTestCase {

}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down Expand Up @@ -347,7 +347,7 @@ class QueryTests : XCTestCase {

}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down Expand Up @@ -398,7 +398,7 @@ class QueryTests : XCTestCase {

}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down Expand Up @@ -447,7 +447,7 @@ class QueryTests : XCTestCase {

}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down Expand Up @@ -505,7 +505,7 @@ class QueryTests : XCTestCase {

}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down Expand Up @@ -563,7 +563,7 @@ class QueryTests : XCTestCase {

}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down Expand Up @@ -611,7 +611,7 @@ class QueryTests : XCTestCase {

}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down Expand Up @@ -670,7 +670,7 @@ class QueryTests : XCTestCase {

}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down Expand Up @@ -728,7 +728,7 @@ class QueryTests : XCTestCase {

}

self.waitForExpectations(withTimeout: 300) { error in
self.waitForExpectations(withTimeout: 600) { error in
if let error = error {
XCTFail("waitForExpectationsWithTimeout errored: \(error)")
}
Expand Down

0 comments on commit 5d3cbd7

Please sign in to comment.