Skip to content

Conversation

@akkrat
Copy link

@akkrat akkrat commented Aug 24, 2022

Fixing #1785
pthread_mutex_t was chosen because

  1. it's already using on some platforms
  2. os_unfair_lock must be allocated on the heap so it couldn't be used as c++ class member (Concurrent Programming With GCD in Swift 3 or SO)

@dinhvh
Copy link
Member

dinhvh commented Aug 25, 2022

pthread_mutex_t is too slow.
We need to use something faster on iOS / macOS.

@akkrat
Copy link
Author

akkrat commented Sep 5, 2022

libetpan uses pthread_mutex_t too
The other alternatives (such as dispatch semaphore or os_unfair_lock) are not much faster than pthread_mutex_t

@dinhvh
Copy link
Member

dinhvh commented Sep 5, 2022 via email

bengotow pushed a commit to Foundry376/Mailspring-Sync that referenced this pull request Jan 1, 2026
Cherry-pick fix from upstream mailcore2 PR #1953.

OSSpinLock is deprecated on Apple platforms since macOS 10.12/iOS 10.0
due to priority inversion issues. This causes deprecation warnings
during compilation.

This fix replaces OSSpinLock with pthread_mutex_t on all platforms,
which is already used on non-Apple platforms. pthread_mutex_t is a
safe, portable alternative that:
1. Avoids priority inversion issues
2. Eliminates platform-specific code paths
3. Is already being used elsewhere in the codebase

Upstream: MailCore/mailcore2#1953
Related: MailCore/mailcore2#1785
bengotow added a commit to Foundry376/Mailspring-Sync that referenced this pull request Jan 1, 2026
Cherry-pick fix from upstream mailcore2 PR #1953.

OSSpinLock is deprecated on Apple platforms since macOS 10.12/iOS 10.0
due to priority inversion issues. This causes deprecation warnings
during compilation.

This fix replaces OSSpinLock with pthread_mutex_t on all platforms,
which is already used on non-Apple platforms. pthread_mutex_t is a
safe, portable alternative that:
1. Avoids priority inversion issues
2. Eliminates platform-specific code paths
3. Is already being used elsewhere in the codebase

Upstream: MailCore/mailcore2#1953
Related: MailCore/mailcore2#1785

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants