{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls/comments/56730200","id":56730200,"diff_hunk":"@@ -11,45 +11,156 @@\n //===----------------------------------------------------------------------===//\n \n @_exported import Dispatch\n-\n-/// The type of blocks submitted to dispatch queues, which take no arguments\n-/// and have no return value.\n-///\n-/// The dispatch_block_t typealias is different from usual closures in that it\n-/// uses @convention(block). This is to avoid unnecessary bridging between\n-/// C blocks and Swift closures, which interferes with Grand Central Dispatch\n-/// APIs that depend on the referential identity of a block.\n-public typealias dispatch_block_t = @convention(block) () -> Void\n+import CDispatch\n \n //===----------------------------------------------------------------------===//\n-// Macros\n-// FIXME: rdar://16851050 update API so these import better\n+// Linux-specific overlay layer to compensate for lack of Objective-C\n+//\n+//   CDispatch classes and APIs are wrapped in Swift objects/functions\n+//   to achieve API compatibility with Darwin platforms and integration with\n+//   Swift retain/release operations.\n+//\n+//   Injecting an extra level of wrapping is sub-optimal, but pushing the Swift\n+//   object model down into the C libdispatch implementation is too invasive\n+//   a change to undertake at this stage of development.\n //===----------------------------------------------------------------------===//\n \n-// dispatch/io.h\n-public var DISPATCH_IO_STREAM: dispatch_io_type_t {\n-  return 0\n+//////////\n+// Define Swift-level class hierarchy for subset of dispatch types\n+// returned from API methods with DISPATCH_RETURNS_RETAINED\n+//////////\n+\n+public typealias dispatch_object_t = DispatchObject\n+public class DispatchObject {","path":"src/swift/Dispatch.swift","position":38,"original_position":38,"commit_id":"733171ddbff4e30a92b1ea30a6206dc09a5386a4","original_commit_id":"733171ddbff4e30a92b1ea30a6206dc09a5386a4","user":{"login":"dgrove-oss","id":5099100,"avatar_url":"https://avatars.githubusercontent.com/u/5099100?v=3","gravatar_id":"","url":"https://api.github.com/users/dgrove-oss","html_url":"https://github.com/dgrove-oss","followers_url":"https://api.github.com/users/dgrove-oss/followers","following_url":"https://api.github.com/users/dgrove-oss/following{/other_user}","gists_url":"https://api.github.com/users/dgrove-oss/gists{/gist_id}","starred_url":"https://api.github.com/users/dgrove-oss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgrove-oss/subscriptions","organizations_url":"https://api.github.com/users/dgrove-oss/orgs","repos_url":"https://api.github.com/users/dgrove-oss/repos","events_url":"https://api.github.com/users/dgrove-oss/events{/privacy}","received_events_url":"https://api.github.com/users/dgrove-oss/received_events","type":"User","site_admin":false},"body":"I think either could work.  I was thinking it might be useful to distinguish between the native and Swift layers of the code, but I really didn't use the capitalized class names outside the declarations.  I could rework if you want. ","created_at":"2016-03-18T22:19:44Z","updated_at":"2016-03-18T22:19:44Z","html_url":"https://github.com/apple/swift-corelibs-libdispatch/pull/61#discussion_r56730200","pull_request_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls/61","_links":{"self":{"href":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls/comments/56730200"},"html":{"href":"https://github.com/apple/swift-corelibs-libdispatch/pull/61#discussion_r56730200"},"pull_request":{"href":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls/61"}}},"pull_request":{"url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls/61","id":63440533,"html_url":"https://github.com/apple/swift-corelibs-libdispatch/pull/61","diff_url":"https://github.com/apple/swift-corelibs-libdispatch/pull/61.diff","patch_url":"https://github.com/apple/swift-corelibs-libdispatch/pull/61.patch","issue_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/issues/61","number":61,"state":"open","locked":false,"title":"Rework of Dispatch overlay for Linux","user":{"login":"dgrove-oss","id":5099100,"avatar_url":"https://avatars.githubusercontent.com/u/5099100?v=3","gravatar_id":"","url":"https://api.github.com/users/dgrove-oss","html_url":"https://github.com/dgrove-oss","followers_url":"https://api.github.com/users/dgrove-oss/followers","following_url":"https://api.github.com/users/dgrove-oss/following{/other_user}","gists_url":"https://api.github.com/users/dgrove-oss/gists{/gist_id}","starred_url":"https://api.github.com/users/dgrove-oss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgrove-oss/subscriptions","organizations_url":"https://api.github.com/users/dgrove-oss/orgs","repos_url":"https://api.github.com/users/dgrove-oss/repos","events_url":"https://api.github.com/users/dgrove-oss/events{/privacy}","received_events_url":"https://api.github.com/users/dgrove-oss/received_events","type":"User","site_admin":false},"body":"The lack of Objective-C and associated bridging\r\nwhen importing the libdispatch header files into Swift\r\ncaused a number of problems including\r\n  (a) missing ref count operations in Swift compiled code\r\n  (b) SR-739, dispatch types not being upcastable to dispatch_object_t\r\n  (c) SR-730, dispatch types not being upcastable to AnyObject\r\n  (d) SR-737, dispatch types being imported as COpaquePointer\r\n\r\nThis commit fixes all of these issues by injecting a complete\r\nSwift overlay layer that wraps the native libdispatch objects\r\nand native APIs.\r\n\r\nThe C header files are now imported into a distinct CDispatch module\r\nthat is not made available to Swift client code (which continues to\r\nimport Dispatch). Code is added to Dispatch.swift to mirror the\r\nnative CDispatch APIs up to the Swift Dispatch API and to wrap/unwrap\r\nvalues as needed across that boundary.\r\n\r\nThis wrapping layer does add some minor space and time overheads,\r\nbut after extensively exploring implementing the Swift object model\r\nwithin the C code of libdispatch (to avoid introducing this overhead),\r\nI concluded that the necessary changes to libdispatch would be fairly\r\ninvasive, and therefore were not justified at this point in the\r\ndevelopment of the Swift/Linux port of libdispatch.","created_at":"2016-03-18T21:44:18Z","updated_at":"2016-03-18T22:19:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6fce667cefd7b6e3358d17ed16d3a6db5b4c8d24","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls/61/commits","review_comments_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls/61/comments","review_comment_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/issues/61/comments","statuses_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/statuses/733171ddbff4e30a92b1ea30a6206dc09a5386a4","head":{"label":"dgrove-oss:full-overlay-pr","ref":"full-overlay-pr","sha":"733171ddbff4e30a92b1ea30a6206dc09a5386a4","user":{"login":"dgrove-oss","id":5099100,"avatar_url":"https://avatars.githubusercontent.com/u/5099100?v=3","gravatar_id":"","url":"https://api.github.com/users/dgrove-oss","html_url":"https://github.com/dgrove-oss","followers_url":"https://api.github.com/users/dgrove-oss/followers","following_url":"https://api.github.com/users/dgrove-oss/following{/other_user}","gists_url":"https://api.github.com/users/dgrove-oss/gists{/gist_id}","starred_url":"https://api.github.com/users/dgrove-oss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgrove-oss/subscriptions","organizations_url":"https://api.github.com/users/dgrove-oss/orgs","repos_url":"https://api.github.com/users/dgrove-oss/repos","events_url":"https://api.github.com/users/dgrove-oss/events{/privacy}","received_events_url":"https://api.github.com/users/dgrove-oss/received_events","type":"User","site_admin":false},"repo":{"id":47428328,"name":"swift-corelibs-libdispatch","full_name":"dgrove-oss/swift-corelibs-libdispatch","owner":{"login":"dgrove-oss","id":5099100,"avatar_url":"https://avatars.githubusercontent.com/u/5099100?v=3","gravatar_id":"","url":"https://api.github.com/users/dgrove-oss","html_url":"https://github.com/dgrove-oss","followers_url":"https://api.github.com/users/dgrove-oss/followers","following_url":"https://api.github.com/users/dgrove-oss/following{/other_user}","gists_url":"https://api.github.com/users/dgrove-oss/gists{/gist_id}","starred_url":"https://api.github.com/users/dgrove-oss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgrove-oss/subscriptions","organizations_url":"https://api.github.com/users/dgrove-oss/orgs","repos_url":"https://api.github.com/users/dgrove-oss/repos","events_url":"https://api.github.com/users/dgrove-oss/events{/privacy}","received_events_url":"https://api.github.com/users/dgrove-oss/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dgrove-oss/swift-corelibs-libdispatch","description":"The libdispatch Project, (a.k.a. Grand Central Dispatch), for concurrency on multicore hardware","fork":true,"url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch","forks_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/forks","keys_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/teams","hooks_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/hooks","issue_events_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/issues/events{/number}","events_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/events","assignees_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/assignees{/user}","branches_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/branches{/branch}","tags_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/tags","blobs_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/git/refs{/sha}","trees_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/statuses/{sha}","languages_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/languages","stargazers_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/stargazers","contributors_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/contributors","subscribers_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/subscribers","subscription_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/subscription","commits_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/commits{/sha}","git_commits_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/git/commits{/sha}","comments_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/comments{/number}","issue_comment_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/issues/comments{/number}","contents_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/contents/{+path}","compare_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/merges","archive_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/downloads","issues_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/issues{/number}","pulls_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/pulls{/number}","milestones_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/milestones{/number}","notifications_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/labels{/name}","releases_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/releases{/id}","deployments_url":"https://api.github.com/repos/dgrove-oss/swift-corelibs-libdispatch/deployments","created_at":"2015-12-04T20:54:44Z","updated_at":"2016-01-11T16:59:40Z","pushed_at":"2016-03-18T21:43:15Z","git_url":"git://github.com/dgrove-oss/swift-corelibs-libdispatch.git","ssh_url":"git@github.com:dgrove-oss/swift-corelibs-libdispatch.git","clone_url":"https://github.com/dgrove-oss/swift-corelibs-libdispatch.git","svn_url":"https://github.com/dgrove-oss/swift-corelibs-libdispatch","homepage":"swift.org","size":671,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"apple:master","ref":"master","sha":"054d938078af66ea2e53d1d54e4b1833a43395ee","user":{"login":"apple","id":10639145,"avatar_url":"https://avatars.githubusercontent.com/u/10639145?v=3","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"repo":{"id":45863965,"name":"swift-corelibs-libdispatch","full_name":"apple/swift-corelibs-libdispatch","owner":{"login":"apple","id":10639145,"avatar_url":"https://avatars.githubusercontent.com/u/10639145?v=3","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apple/swift-corelibs-libdispatch","description":"The libdispatch Project, (a.k.a. Grand Central Dispatch), for concurrency on multicore hardware","fork":false,"url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch","forks_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/forks","keys_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/teams","hooks_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/hooks","issue_events_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/issues/events{/number}","events_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/events","assignees_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/assignees{/user}","branches_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/branches{/branch}","tags_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/tags","blobs_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/git/refs{/sha}","trees_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/statuses/{sha}","languages_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/languages","stargazers_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/stargazers","contributors_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/contributors","subscribers_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/subscribers","subscription_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/subscription","commits_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/commits{/sha}","git_commits_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/git/commits{/sha}","comments_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/comments{/number}","issue_comment_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/issues/comments{/number}","contents_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/contents/{+path}","compare_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/merges","archive_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/downloads","issues_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/issues{/number}","pulls_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls{/number}","milestones_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/milestones{/number}","notifications_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/labels{/name}","releases_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/releases{/id}","deployments_url":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/deployments","created_at":"2015-11-09T20:13:55Z","updated_at":"2016-03-17T22:24:36Z","pushed_at":"2016-03-18T21:44:18Z","git_url":"git://github.com/apple/swift-corelibs-libdispatch.git","ssh_url":"git@github.com:apple/swift-corelibs-libdispatch.git","clone_url":"https://github.com/apple/swift-corelibs-libdispatch.git","svn_url":"https://github.com/apple/swift-corelibs-libdispatch","homepage":"swift.org","size":747,"stargazers_count":643,"watchers_count":643,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":82,"mirror_url":null,"open_issues_count":5,"forks":82,"open_issues":5,"watchers":643,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls/61"},"html":{"href":"https://github.com/apple/swift-corelibs-libdispatch/pull/61"},"issue":{"href":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/issues/61"},"comments":{"href":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/issues/61/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls/61/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/pulls/61/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift-corelibs-libdispatch/statuses/733171ddbff4e30a92b1ea30a6206dc09a5386a4"}}}}