diff options
| author | Shawn O. Pearce <spearce@spearce.org> | 2009-01-03 00:02:25 -0800 |
|---|---|---|
| committer | Shawn O. Pearce <spearce@spearce.org> | 2009-01-03 00:02:25 -0800 |
| commit | 098ac57a13165290bad223e4949fc6f13960b604 (patch) | |
| tree | ed8ab62f1be3062011dbb3c6033952e4657abd94 /src/fileops.c | |
| parent | 3a33c7b37f55d5bd30ff944625499e64919b9a9d (diff) | |
| download | libgit2-098ac57a13165290bad223e4949fc6f13960b604.tar.gz | |
Refactor pack memory management and locking to be safer
Using an atomic reference counter is difficult to make
cross-platform, as the reference count implementations
are generally processor specific. Its also hard to do
a proper multi-read/single-write implementation.
We now use a simple mutex around the reference count for the list
of packs. Readers grab the mutex and either build the list, or
increment the existing one's reference count. When the reader is
done with the list, the reference count is decremented. In this way
parallel readers are able to operate on the list without worrying
about it being deallocated out from under them.
Individual pack structures are held by reference counts, but we
only care about the list the pack structure is held in. There is
no need to increment/decrement the pack reference counts as we
scan through them during a read operation, the caller holds the
git_packlist and that is sufficient to hold the packs it references.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'src/fileops.c')
0 files changed, 0 insertions, 0 deletions
