You can use GCD. It is a little more verbose than @synchronized
, but works as a replacement:
let serialQueue = DispatchQueue(label: "com.test.mySerialQueue")
serialQueue.sync {
// code
}
More Related Contents:
- What is the difference between lock, mutex and semaphore?
- What is a good pattern for using a Global Mutex in C#?
- What is a mutex?
- SSE instructions: which CPUs can do atomic 16B memory operations?
- Is x86 CMPXCHG atomic, if so why does it need LOCK?
- NSURLSession concurrent requests with Alamofire
- Would you explain lock ordering?
- NSPersistentContainer concurrency for saving to core data
- What is a coroutine?
- What is mutex and semaphore in Java ? What is the main difference?
- Difference between DispatchQueue.main.async and DispatchQueue.main.sync
- What is a memory fence?
- If I am using channels properly should I need to use mutexes?
- How are mutexes implemented?
- How does LMAX’s disruptor pattern work?
- How do I atomically increment a variable in Swift?
- Trouble running async functions in background threads (concurrency)
- How do goroutines work? (or: goroutines and OS threads relation)
- anonymous struct and empty struct
- How to configure concurrency in .NET Core Web API?
- Use queue and semaphore for concurrency and property wrapper?
- Are POSIX’ read() and write() system calls atomic?
- What exactly does runtime.Gosched do?
- How To Download Multiple Files Sequentially using NSURLSession downloadTask in Swift
- Swift 4 “This class is not key value coding compliant”
- How can I convert a String to an MD5 hash in iOS using Swift?
- Could not find a valid GoogleService-Info.plist in your project
- UITableViewCell: rounded corners and shadow
- In SQL Server, how can I lock a single row in a way similar to Oracle’s “SELECT FOR UPDATE WAIT”?
- JSON Parsing in Swift 3