Skip to content
This repository has been archived by the owner on Apr 4, 2018. It is now read-only.

Commit

Permalink
revert to using non-optional types for rawValue.
Browse files Browse the repository at this point in the history
  • Loading branch information
anpol committed Dec 9, 2015
1 parent afd5aca commit 8ff6ea1
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
8 changes: 4 additions & 4 deletions Sources/DispatchData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public struct DispatchData<T: IntegerType>: DispatchObject {
return DispatchData(raw: dispatch_data_empty)
}

public let data: dispatch_data_t
public var rawValue: dispatch_object_t {
public let data: dispatch_data_t!

public var rawValue: dispatch_object_t! {
return data
}

public init(raw data: dispatch_data_t) {
public init(raw data: dispatch_data_t!) {
self.data = data
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/DispatchGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import Foundation

public struct DispatchGroup: DispatchObject, DispatchEnterable, DispatchWaitable {

public let group: dispatch_group_t
public var rawValue: dispatch_object_t {
public let group: dispatch_group_t!

public var rawValue: dispatch_object_t! {
return group
}

public init(raw group: dispatch_group_t) {
public init(raw group: dispatch_group_t!) {
self.group = group
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/DispatchIO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public typealias DispatchIOIntervalFlags = DKDispatchIOIntervalFlags

public struct DispatchIO: DispatchObject {

public let io: dispatch_io_t
public var rawValue: dispatch_object_t {
public let io: dispatch_io_t!

public var rawValue: dispatch_object_t! {
return io
}

public init(raw io: dispatch_io_t) {
public init(raw io: dispatch_io_t!) {
self.io = io
}

Expand Down
3 changes: 1 addition & 2 deletions Sources/DispatchObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public protocol DispatchCookie: class {
}

public protocol DispatchObject {

var rawValue: dispatch_object_t { get }
var rawValue: dispatch_object_t! { get }
func getContext<Cookie: DispatchCookie>() -> Cookie?
func setContext<Cookie: DispatchCookie>(context: Cookie?)

Expand Down
8 changes: 4 additions & 4 deletions Sources/DispatchQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ internal func dk_dispatch_queue_create_with_qos_class(label: String!, attr: disp

public struct DispatchQueue: DispatchObject, DispatchResumable {

public let queue: dispatch_queue_t
public var rawValue: dispatch_object_t {
public let queue: dispatch_queue_t!

public var rawValue: dispatch_object_t! {
return queue
}

public init(raw queue: dispatch_queue_t) {
public init(raw queue: dispatch_queue_t!) {
self.queue = queue
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/DispatchSemaphore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import Foundation

public struct DispatchSemaphore: DispatchObject, DispatchWaitable {

public let semaphore: dispatch_semaphore_t
public var rawValue: dispatch_object_t {
public let semaphore: dispatch_semaphore_t!

public var rawValue: dispatch_object_t! {
return semaphore
}

public init(raw semaphore: dispatch_semaphore_t) {
public init(raw semaphore: dispatch_semaphore_t!) {
self.semaphore = semaphore
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/DispatchSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import Foundation

public struct DispatchSource: DispatchObject, DispatchResumable, DispatchCancelable {

public let source: dispatch_source_t
public var rawValue: dispatch_object_t {
public let source: dispatch_source_t!

public var rawValue: dispatch_object_t! {
return source
}

public init(raw source: dispatch_source_t) {
public init(raw source: dispatch_source_t!) {
self.source = source
}

Expand Down

4 comments on commit 8ff6ea1

@ElvishJerricco
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand why these need to all be implicitly unwrapped optionals? Have I missed something? Why isn't it better for them to be straight non-optionals?

@anpol
Copy link
Owner Author

@anpol anpol commented on 8ff6ea1 Dec 11, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most libdispatch functions could return NULL, currently we are not handling this, so we should at least propagate them as optionals to the users of DispatchKit.

@ElvishJerricco
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. Perhaps it would be best to make them non-optional and have those initializers which call dispatch_create_X functions changed to optional initializers? This way the wrapper object is treated as optional rather than haphazardly using an optional within the wrapper object.

@anpol
Copy link
Owner Author

@anpol anpol commented on 8ff6ea1 Dec 11, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, failable initializers were born after that code was written, we should definitely migrate to them.

Please sign in to comment.