{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift/pulls/comments/57966352","id":57966352,"diff_hunk":"@@ -0,0 +1,102 @@\n+//===--- MutexPThread.h - ---------------------------------------*- C++ -*-===//\n+//\n+// This source file is part of the Swift.org open source project\n+//\n+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors\n+// Licensed under Apache License v2.0 with Runtime Library Exception\n+//\n+// See http://swift.org/LICENSE.txt for license information\n+// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors\n+//\n+//===----------------------------------------------------------------------===//\n+//\n+// Mutex, Condition, Read/Write lock, and Scoped lock implementations\n+// using PThreads.\n+//\n+//===----------------------------------------------------------------------===//\n+\n+#ifndef SWIFT_RUNTIME_MUTEX_PHTREAD_H\n+#define SWIFT_RUNTIME_MUTEX_PHTREAD_H\n+\n+#include <pthread.h>\n+\n+namespace swift {\n+\n+/// Private PThread implementation of Condition functionality.\n+/// Use Condition instead (see Mutex.h).\n+class ConditionImpl {\n+  friend class MutexImpl;\n+  friend class Condition;\n+\n+  ConditionImpl(const ConditionImpl &) = delete;\n+  ConditionImpl &operator=(const ConditionImpl &) = delete;\n+  ConditionImpl(ConditionImpl &&) = delete;\n+  ConditionImpl &operator=(ConditionImpl &&) = delete;\n+\n+public:\n+  ~ConditionImpl();\n+\n+public:\n+  void notifyOne();\n+  void notifyAll();\n+\n+private:\n+  explicit ConditionImpl(bool reportFatal);\n+  bool ReportFatal;\n+  pthread_cond_t PThreadCond;\n+};\n+\n+/// Private PThread implementation of Mutex functionality.\n+/// Use Mutex instead (see Mutex.h).\n+class MutexImpl {\n+  friend class Mutex;\n+\n+  MutexImpl() = delete;\n+  MutexImpl(const MutexImpl &) = delete;\n+  MutexImpl &operator=(const MutexImpl &) = delete;\n+  MutexImpl(MutexImpl &&) = delete;\n+  MutexImpl &operator=(MutexImpl &&) = delete;\n+\n+public:\n+  ~MutexImpl();\n+\n+public:\n+  void lock();\n+  void unlock();\n+  bool try_lock();\n+  void wait(ConditionImpl &condition);\n+\n+private:\n+  explicit MutexImpl(bool reportFatal, bool checked);\n+  bool ReportFatal;","path":"include/swift/Runtime/MutexPThread.h","position":71,"original_position":71,"commit_id":"a712795d166501ea7942e2c642281cb2248c5d31","original_commit_id":"a712795d166501ea7942e2c642281cb2248c5d31","user":{"login":"shawnce","id":352255,"avatar_url":"https://avatars.githubusercontent.com/u/352255?v=3","gravatar_id":"","url":"https://api.github.com/users/shawnce","html_url":"https://github.com/shawnce","followers_url":"https://api.github.com/users/shawnce/followers","following_url":"https://api.github.com/users/shawnce/following{/other_user}","gists_url":"https://api.github.com/users/shawnce/gists{/gist_id}","starred_url":"https://api.github.com/users/shawnce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shawnce/subscriptions","organizations_url":"https://api.github.com/users/shawnce/orgs","repos_url":"https://api.github.com/users/shawnce/repos","events_url":"https://api.github.com/users/shawnce/events{/privacy}","received_events_url":"https://api.github.com/users/shawnce/received_events","type":"User","site_admin":false},"body":"Will work on leveraging a template parameter for this and checked, unless you think I should just drop checked? It helps trap issues when running tests and in theory newly written code could leverage it to help flag issues in what they wrote before going into production, etc. The later could be predicated on build type as well. In really only applies to non-reclusive mutex since the other lock types need to maintain more state anyways giving you misuse detection \"for free\".","created_at":"2016-03-30T21:23:06Z","updated_at":"2016-03-30T21:23:06Z","html_url":"https://github.com/apple/swift/pull/1950#discussion_r57966352","pull_request_url":"https://api.github.com/repos/apple/swift/pulls/1950","_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/comments/57966352"},"html":{"href":"https://github.com/apple/swift/pull/1950#discussion_r57966352"},"pull_request":{"href":"https://api.github.com/repos/apple/swift/pulls/1950"}}},"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/1950","id":64592306,"html_url":"https://github.com/apple/swift/pull/1950","diff_url":"https://github.com/apple/swift/pull/1950.diff","patch_url":"https://github.com/apple/swift/pull/1950.patch","issue_url":"https://api.github.com/repos/apple/swift/issues/1950","number":1950,"state":"open","locked":false,"title":"[runtime] enhanced and refactored recently added Mutex abstraction","user":{"login":"shawnce","id":352255,"avatar_url":"https://avatars.githubusercontent.com/u/352255?v=3","gravatar_id":"","url":"https://api.github.com/users/shawnce","html_url":"https://github.com/shawnce","followers_url":"https://api.github.com/users/shawnce/followers","following_url":"https://api.github.com/users/shawnce/following{/other_user}","gists_url":"https://api.github.com/users/shawnce/gists{/gist_id}","starred_url":"https://api.github.com/users/shawnce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shawnce/subscriptions","organizations_url":"https://api.github.com/users/shawnce/orgs","repos_url":"https://api.github.com/users/shawnce/repos","events_url":"https://api.github.com/users/shawnce/events{/privacy}","received_events_url":"https://api.github.com/users/shawnce/received_events","type":"User","site_admin":false},"body":"<!-- Please complete this template before creating pull request. -->\r\n- added read / write lock support\r\n- added non-fatal error support to allow use of mutex in fatal error reporting pathway\r\n- isolated pthread implementation to it own header/cpp file pair\r\n- expanded unit tests to cover new code as well as better test existing mutex\r\n\r\n#### Resolved bug number: ([SR-946](https://bugs.swift.org/browse/SR-946))\r\n<!-- If this pull request resolves any bugs from Swift bug tracker -->\r\n\r\n* * * *\r\n\r\n<!-- This selection should only be completed by Swift admin -->\r\nBefore merging this pull request to apple/swift repository:\r\n- [ ] Test pull request on Swift continuous integration.\r\n\r\n<details>\r\n  <summary>Triggering Swift CI</summary>\r\n\r\nThe swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:\r\n\r\n**Smoke Testing**\r\n\r\n        Platform     | Comment\r\n        ------------ | -------------\r\n        All supported platforms     | @swift-ci Please smoke test\r\n        OS X platform               | @swift-ci Please smoke test OS X platform\r\n        Linux platform              | @swift-ci Please smoke test Linux platform\r\n\r\n **Validation Testing**\r\n\r\n        Platform     | Comment\r\n        ------------ | -------------\r\n        All supported platforms     | @swift-ci Please test\r\n        OS X platform               | @swift-ci Please test OS X platform\r\n        Linux platform              | @swift-ci Please test Linux platform\r\n\r\nNote: Only members of the Apple organization can trigger swift-ci.\r\n</details>\r\n<!-- Thank you for your contribution to Swift! -->\r\n","created_at":"2016-03-30T08:55:49Z","updated_at":"2016-03-30T21:23:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd8769376e2534a1a8f717b0c842c6ca21821097","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift/pulls/1950/commits","review_comments_url":"https://api.github.com/repos/apple/swift/pulls/1950/comments","review_comment_url":"https://api.github.com/repos/apple/swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift/issues/1950/comments","statuses_url":"https://api.github.com/repos/apple/swift/statuses/a712795d166501ea7942e2c642281cb2248c5d31","head":{"label":"shawnce:SR-946_rw","ref":"SR-946_rw","sha":"a712795d166501ea7942e2c642281cb2248c5d31","user":{"login":"shawnce","id":352255,"avatar_url":"https://avatars.githubusercontent.com/u/352255?v=3","gravatar_id":"","url":"https://api.github.com/users/shawnce","html_url":"https://github.com/shawnce","followers_url":"https://api.github.com/users/shawnce/followers","following_url":"https://api.github.com/users/shawnce/following{/other_user}","gists_url":"https://api.github.com/users/shawnce/gists{/gist_id}","starred_url":"https://api.github.com/users/shawnce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shawnce/subscriptions","organizations_url":"https://api.github.com/users/shawnce/orgs","repos_url":"https://api.github.com/users/shawnce/repos","events_url":"https://api.github.com/users/shawnce/events{/privacy}","received_events_url":"https://api.github.com/users/shawnce/received_events","type":"User","site_admin":false},"repo":{"id":47999652,"name":"swift","full_name":"shawnce/swift","owner":{"login":"shawnce","id":352255,"avatar_url":"https://avatars.githubusercontent.com/u/352255?v=3","gravatar_id":"","url":"https://api.github.com/users/shawnce","html_url":"https://github.com/shawnce","followers_url":"https://api.github.com/users/shawnce/followers","following_url":"https://api.github.com/users/shawnce/following{/other_user}","gists_url":"https://api.github.com/users/shawnce/gists{/gist_id}","starred_url":"https://api.github.com/users/shawnce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shawnce/subscriptions","organizations_url":"https://api.github.com/users/shawnce/orgs","repos_url":"https://api.github.com/users/shawnce/repos","events_url":"https://api.github.com/users/shawnce/events{/privacy}","received_events_url":"https://api.github.com/users/shawnce/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shawnce/swift","description":"The Swift Programming Language","fork":true,"url":"https://api.github.com/repos/shawnce/swift","forks_url":"https://api.github.com/repos/shawnce/swift/forks","keys_url":"https://api.github.com/repos/shawnce/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shawnce/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shawnce/swift/teams","hooks_url":"https://api.github.com/repos/shawnce/swift/hooks","issue_events_url":"https://api.github.com/repos/shawnce/swift/issues/events{/number}","events_url":"https://api.github.com/repos/shawnce/swift/events","assignees_url":"https://api.github.com/repos/shawnce/swift/assignees{/user}","branches_url":"https://api.github.com/repos/shawnce/swift/branches{/branch}","tags_url":"https://api.github.com/repos/shawnce/swift/tags","blobs_url":"https://api.github.com/repos/shawnce/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shawnce/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shawnce/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/shawnce/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shawnce/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/shawnce/swift/languages","stargazers_url":"https://api.github.com/repos/shawnce/swift/stargazers","contributors_url":"https://api.github.com/repos/shawnce/swift/contributors","subscribers_url":"https://api.github.com/repos/shawnce/swift/subscribers","subscription_url":"https://api.github.com/repos/shawnce/swift/subscription","commits_url":"https://api.github.com/repos/shawnce/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/shawnce/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/shawnce/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/shawnce/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/shawnce/swift/contents/{+path}","compare_url":"https://api.github.com/repos/shawnce/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shawnce/swift/merges","archive_url":"https://api.github.com/repos/shawnce/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shawnce/swift/downloads","issues_url":"https://api.github.com/repos/shawnce/swift/issues{/number}","pulls_url":"https://api.github.com/repos/shawnce/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/shawnce/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/shawnce/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shawnce/swift/labels{/name}","releases_url":"https://api.github.com/repos/shawnce/swift/releases{/id}","deployments_url":"https://api.github.com/repos/shawnce/swift/deployments","created_at":"2015-12-14T20:32:42Z","updated_at":"2016-02-21T06:24:28Z","pushed_at":"2016-03-30T20:17:08Z","git_url":"git://github.com/shawnce/swift.git","ssh_url":"git@github.com:shawnce/swift.git","clone_url":"https://github.com/shawnce/swift.git","svn_url":"https://github.com/shawnce/swift","homepage":"https://swift.org/","size":84123,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"apple:master","ref":"master","sha":"b332321457e3172a2399287c74722fbc36214872","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":44838949,"name":"swift","full_name":"apple/swift","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","description":"The Swift Programming Language","fork":false,"url":"https://api.github.com/repos/apple/swift","forks_url":"https://api.github.com/repos/apple/swift/forks","keys_url":"https://api.github.com/repos/apple/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apple/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apple/swift/teams","hooks_url":"https://api.github.com/repos/apple/swift/hooks","issue_events_url":"https://api.github.com/repos/apple/swift/issues/events{/number}","events_url":"https://api.github.com/repos/apple/swift/events","assignees_url":"https://api.github.com/repos/apple/swift/assignees{/user}","branches_url":"https://api.github.com/repos/apple/swift/branches{/branch}","tags_url":"https://api.github.com/repos/apple/swift/tags","blobs_url":"https://api.github.com/repos/apple/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apple/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apple/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/apple/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apple/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/apple/swift/languages","stargazers_url":"https://api.github.com/repos/apple/swift/stargazers","contributors_url":"https://api.github.com/repos/apple/swift/contributors","subscribers_url":"https://api.github.com/repos/apple/swift/subscribers","subscription_url":"https://api.github.com/repos/apple/swift/subscription","commits_url":"https://api.github.com/repos/apple/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/apple/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/apple/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/apple/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/apple/swift/contents/{+path}","compare_url":"https://api.github.com/repos/apple/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apple/swift/merges","archive_url":"https://api.github.com/repos/apple/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apple/swift/downloads","issues_url":"https://api.github.com/repos/apple/swift/issues{/number}","pulls_url":"https://api.github.com/repos/apple/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/apple/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/apple/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apple/swift/labels{/name}","releases_url":"https://api.github.com/repos/apple/swift/releases{/id}","deployments_url":"https://api.github.com/repos/apple/swift/deployments","created_at":"2015-10-23T21:15:07Z","updated_at":"2016-03-30T20:54:55Z","pushed_at":"2016-03-30T21:03:58Z","git_url":"git://github.com/apple/swift.git","ssh_url":"git@github.com:apple/swift.git","clone_url":"https://github.com/apple/swift.git","svn_url":"https://github.com/apple/swift","homepage":"https://swift.org/","size":115609,"stargazers_count":28171,"watchers_count":28171,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3707,"mirror_url":null,"open_issues_count":80,"forks":3707,"open_issues":80,"watchers":28171,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/1950"},"html":{"href":"https://github.com/apple/swift/pull/1950"},"issue":{"href":"https://api.github.com/repos/apple/swift/issues/1950"},"comments":{"href":"https://api.github.com/repos/apple/swift/issues/1950/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift/pulls/1950/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift/pulls/1950/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift/statuses/a712795d166501ea7942e2c642281cb2248c5d31"}}}}