Company
Date Published
Author
Amy Palamountain
Word count
1353
Language
English
Hacker News points
None

Summary

Careful concurrency management is crucial for maintaining a responsive user interface in GitHub Desktop, a native application for Mac and Windows, which utilizes both libgit2 and the git command line to interact with repositories. Due to the inherent differences in how git and libgit2 handle concurrency—with git using pessimistic locks and libgit2 not being inherently thread-safe—the development team devised a novel concurrency model to handle asynchronous operations using Microsoft’s Reactive Extensions and ReactiveCocoa. This model categorizes operations as either concurrent or exclusive, utilizing an AsyncReaderWriterLock to manage these operations and ensure they execute safely without data corruption. By organizing tasks into units of work and executing them as atomic operations, GitHub Desktop ensures that complex tasks can be performed without compromising the application’s responsiveness or the integrity of the repositories. This approach addresses previous stability and performance issues, preventing race conditions and maintaining a high level of concurrency control.