Last active
September 15, 2015 15:10
-
-
Save ammeep/7de072ce3bc808c2d25e to your computer and use it in GitHub Desktop.
A C# example of how we might use locks inside GitHub Desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LockExample | |
{ | |
private IRepository repository; | |
public LockExample(IRepository repository) | |
{ | |
this.repository = repository; | |
} | |
public IObservable<Unit> Fetch() | |
{ | |
// execute a git fetch | |
} | |
public IObservable<Unit> FindMergeBase(Sha first, Sha second) | |
{ | |
// calculate the merge base between two sha's | |
} | |
public IObservable<Unit> Commit() | |
{ | |
// create a commit | |
} | |
public void DoWork(Sha first, Sha second) | |
{ | |
repository.WithConcurrentConnection(Fetch) | |
.Subscribe(); | |
repository.WithConcurrentConnection(FindMergeBase(first, second)) | |
.Subscribe(); | |
repository.WithExclusiveConnection(Commit) | |
.Subscribe(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment