Struct git_repository::EasyArcExclusive [−][src]
pub struct EasyArcExclusive {
pub repo: Arc<RwLock<Repository>>,
pub state: State,
}
Expand description
A handle to a optionally mutable Repository
for use in long-running applications that eventually need to update the Repository
to adapt to changes they triggered or that were caused by other processes.
Using it incurs costs as each Repository
access has to go through an indirection and involve an eventually fair RwLock
.
However, it’s vital to precisely updating the Repository
instance as opposed to creating a new one while serving other requests
on an old instance, which potentially duplicates the resource costs.
Limitation
- It can take a long time to get a mutable
repo
….- Imagine a typical server operation where a pack is sent to a client. As it’s a fresh clone it takes 5 minutes. Right after the clone began somebody initiates a push. Everything goes well and as a new pack was created the server wants to tell the object database to update its packs, making the new one available. To do that, it needs mutable access to the repository instance, and obtaining it will take until the end of the ongoing clone as the latter has acquired read-access to the same repository instance. This is most certainly undesirable.
- Workarounds would be to
- acquire the read-lock each time the clone operation wants to access an object
- set a flag that triggers the server to create a new
Repository
instance next time a connection comes in which is subsequently shared across additional connections. - Create a new
Repository
per connection.
Fields
repo: Arc<RwLock<Repository>>
The repository
state: State
The state with interior mutability
Trait Implementations
type RepoRef = ArcRwLockReadGuard<RawRwLock, Repository>
type RepoRef = ArcRwLockReadGuard<RawRwLock, Repository>
The type of a shared borrow to the Repository
type RepoRefMut = ArcRwLockWriteGuard<RawRwLock, Repository>
type RepoRefMut = ArcRwLockWriteGuard<RawRwLock, Repository>
The type of a mutable borrow to the Repository
Return a shared borrow to the repository. Read more
Returns a mutable borrow to the repository if possible. Read more
Performs the conversion.
Auto Trait Implementations
impl !RefUnwindSafe for EasyArcExclusive
impl Send for EasyArcExclusive
impl !Sync for EasyArcExclusive
impl Unpin for EasyArcExclusive
impl !UnwindSafe for EasyArcExclusive
Blanket Implementations
Mutably borrows from an owned value. Read more