{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift/pulls/comments/58091057","id":58091057,"diff_hunk":"@@ -0,0 +1,118 @@\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();\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 checked);\n+  pthread_mutex_t PThreadMutex;\n+};\n+\n+/// Private PThread implementation of ReadWriteLock functionality.\n+/// Use ReadWriteLock instead (see Mutex.h).\n+class ReadWriteLockImpl {\n+  friend class ReadWriteLock;\n+\n+  ReadWriteLockImpl(const ReadWriteLockImpl &) = delete;\n+  ReadWriteLockImpl &operator=(const ReadWriteLockImpl &) = delete;\n+  ReadWriteLockImpl(ReadWriteLockImpl &&) = delete;\n+  ReadWriteLockImpl &operator=(ReadWriteLockImpl &&) = delete;\n+\n+public:\n+  ~ReadWriteLockImpl();\n+\n+public:\n+  void readLock();\n+  bool try_readLock();\n+  void writeLock();\n+  bool try_writeLock();\n+  void unlock();\n+\n+private:\n+  explicit ReadWriteLockImpl();\n+  pthread_rwlock_t PTheadRWLock;\n+};\n+\n+/// Use UnsafeMutex instead (see Mutex.h).\n+class UnsafeMutexImpl {\n+  friend class UnsafeMutex;\n+\n+  UnsafeMutexImpl(const UnsafeMutexImpl &) = delete;\n+  UnsafeMutexImpl &operator=(const UnsafeMutexImpl &) = delete;\n+  UnsafeMutexImpl(UnsafeMutexImpl &&) = delete;\n+  UnsafeMutexImpl &operator=(UnsafeMutexImpl &&) = delete;\n+\n+public:\n+  ~UnsafeMutexImpl() { pthread_mutex_destroy(&PThreadMutex); }","path":"include/swift/Runtime/MutexPThread.h","position":108,"original_position":108,"commit_id":"aee536cf10a760da8eff862955ea7c717512c7f8","original_commit_id":"09e8abcf2fb9eb31dc94b61b892019a9e617eef6","user":{"login":"jckarter","id":147281,"avatar_url":"https://avatars.githubusercontent.com/u/147281?v=3","gravatar_id":"","url":"https://api.github.com/users/jckarter","html_url":"https://github.com/jckarter","followers_url":"https://api.github.com/users/jckarter/followers","following_url":"https://api.github.com/users/jckarter/following{/other_user}","gists_url":"https://api.github.com/users/jckarter/gists{/gist_id}","starred_url":"https://api.github.com/users/jckarter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jckarter/subscriptions","organizations_url":"https://api.github.com/users/jckarter/orgs","repos_url":"https://api.github.com/users/jckarter/repos","events_url":"https://api.github.com/users/jckarter/events{/privacy}","received_events_url":"https://api.github.com/users/jckarter/received_events","type":"User","site_admin":false},"body":"I think `StaticMutex` might be a better name too.","created_at":"2016-03-31T17:11:56Z","updated_at":"2016-03-31T17:11:56Z","html_url":"https://github.com/apple/swift/pull/1950#discussion_r58091057","pull_request_url":"https://api.github.com/repos/apple/swift/pulls/1950","_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/comments/58091057"},"html":{"href":"https://github.com/apple/swift/pull/1950#discussion_r58091057"},"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":"WIP [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-31T17:11:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"77a508da27d459481918a71878e6160004256a65","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/aee536cf10a760da8eff862955ea7c717512c7f8","head":{"label":"shawnce:SR-946_rw","ref":"SR-946_rw","sha":"aee536cf10a760da8eff862955ea7c717512c7f8","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-31T16:47:24Z","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":84375,"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":"b8aa73788fdb64d775ae3ac405c3fa8d215d0e67","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-31T16:56:19Z","pushed_at":"2016-03-31T17:04:27Z","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":115864,"stargazers_count":28205,"watchers_count":28205,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3714,"mirror_url":null,"open_issues_count":78,"forks":3714,"open_issues":78,"watchers":28205,"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/aee536cf10a760da8eff862955ea7c717512c7f8"}}}}