{"action":"created","issue":{"url":"https://api.github.com/repos/FutureKit/FutureKit/issues/27","labels_url":"https://api.github.com/repos/FutureKit/FutureKit/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/FutureKit/FutureKit/issues/27/comments","events_url":"https://api.github.com/repos/FutureKit/FutureKit/issues/27/events","html_url":"https://github.com/FutureKit/FutureKit/pull/27","id":124548156,"number":27,"title":"Remove OSSpinLockSynchronization","user":{"login":"heiberg","id":803370,"avatar_url":"https://avatars.githubusercontent.com/u/803370?v=3","gravatar_id":"","url":"https://api.github.com/users/heiberg","html_url":"https://github.com/heiberg","followers_url":"https://api.github.com/users/heiberg/followers","following_url":"https://api.github.com/users/heiberg/following{/other_user}","gists_url":"https://api.github.com/users/heiberg/gists{/gist_id}","starred_url":"https://api.github.com/users/heiberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heiberg/subscriptions","organizations_url":"https://api.github.com/users/heiberg/orgs","repos_url":"https://api.github.com/users/heiberg/repos","events_url":"https://api.github.com/users/heiberg/events{/privacy}","received_events_url":"https://api.github.com/users/heiberg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-01T15:32:49Z","updated_at":"2016-01-02T17:38:34Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/FutureKit/FutureKit/pulls/27","html_url":"https://github.com/FutureKit/FutureKit/pull/27","diff_url":"https://github.com/FutureKit/FutureKit/pull/27.diff","patch_url":"https://github.com/FutureKit/FutureKit/pull/27.patch"},"body":"## Summary\r\n\r\nThis pull request removes OSSpinLock as a supported synchronization mechanism.\r\n\r\nAdditionally, the default locking strategy is changed from OSSpinLock to PThreadMutex.\r\n\r\n## Motivation\r\n\r\nThere's a post on the swift-dev mailing list from Dec 14, where John McCall of Apple explicitly states that [using OSSpinLock on iOS is illegal.](https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000321.html)\r\n\r\nLater, David Smith (also from Apple) [stated on Twitter](https://twitter.com/Catfish_Man/status/676851988596809728) that this is not confined to iOS but also affects OS X due to the throttling and priority shuffling done on the new 12\" MacBook.\r\n\r\nApparently the issue is that lock acquisition from a high priority thread may fail indefinitely in case of a priority inversion, where the lock is already held by a low priority thread. The spinning done by the higher priority thread to acquire the lock can prevent the low priority thread from ever completing its work and releasing the lock. The result is effectively a deadlock.\r\n\r\nA more in depth discussion on the topic [can be found here.](http://engineering.postmates.com/Spinlocks-Considered-Harmful-On-iOS/)\r\n\r\nPThreadMutex was chosen as the new default as it is reportedly the underlying mechanism used to implement NSLock, but [experimentally it has a slightly smaller overhead.](http://perpendiculo.us/2009/09/synchronized-nslock-pthread-osspinlock-showdown-done-right/) \r\n\r\n## Implications\r\n\r\nExisting code relying on the default locking strategy is likely to see a minor performance hit on the locking/unlocking operations.\r\n"},"comment":{"url":"https://api.github.com/repos/FutureKit/FutureKit/issues/comments/168411728","html_url":"https://github.com/FutureKit/FutureKit/pull/27#issuecomment-168411728","issue_url":"https://api.github.com/repos/FutureKit/FutureKit/issues/27","id":168411728,"user":{"login":"mishagray","id":303665,"avatar_url":"https://avatars.githubusercontent.com/u/303665?v=3","gravatar_id":"","url":"https://api.github.com/users/mishagray","html_url":"https://github.com/mishagray","followers_url":"https://api.github.com/users/mishagray/followers","following_url":"https://api.github.com/users/mishagray/following{/other_user}","gists_url":"https://api.github.com/users/mishagray/gists{/gist_id}","starred_url":"https://api.github.com/users/mishagray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mishagray/subscriptions","organizations_url":"https://api.github.com/users/mishagray/orgs","repos_url":"https://api.github.com/users/mishagray/repos","events_url":"https://api.github.com/users/mishagray/events{/privacy}","received_events_url":"https://api.github.com/users/mishagray/received_events","type":"User","site_admin":false},"created_at":"2016-01-02T17:38:34Z","updated_at":"2016-01-02T17:38:34Z","body":"Well.  I can't even get confirmation that pthreads are better.  (Pthread vs NSlock).     \r\nOh well.\r\n"}}