Merge pull request #611 from matthiasbeyer/libimagstore/drop-wlocks-early
Libimagstore/drop wlocks early
This commit is contained in:
commit
76d88e46ad
1 changed files with 63 additions and 54 deletions
|
@ -390,6 +390,7 @@ impl Store {
|
|||
.map_err_into(SEK::CreateCallError)
|
||||
}
|
||||
|
||||
{
|
||||
let mut hsmap = match self.entries.write() {
|
||||
Err(_) => return Err(SEK::LockPoisoned.into_error()).map_err_into(SEK::CreateCallError),
|
||||
Ok(s) => s,
|
||||
|
@ -403,6 +404,7 @@ impl Store {
|
|||
se.status = StoreEntryStatus::Borrowed;
|
||||
se
|
||||
});
|
||||
}
|
||||
|
||||
let mut fle = FileLockEntry::new(self, Entry::new(id));
|
||||
self.execute_hooks_for_mut_file(self.post_create_aspects.clone(), &mut fle)
|
||||
|
@ -426,6 +428,7 @@ impl Store {
|
|||
.map_err_into(SEK::RetrieveCallError)
|
||||
}
|
||||
|
||||
let entry = try!({
|
||||
self.entries
|
||||
.write()
|
||||
.map_err(|_| SE::new(SEK::LockPoisoned, None))
|
||||
|
@ -435,14 +438,15 @@ impl Store {
|
|||
se.status = StoreEntryStatus::Borrowed;
|
||||
entry
|
||||
})
|
||||
.map(|e| FileLockEntry::new(self, e))
|
||||
.and_then(|mut fle| {
|
||||
.map_err_into(SEK::RetrieveCallError)
|
||||
});
|
||||
|
||||
let mut fle = FileLockEntry::new(self, entry);
|
||||
self.execute_hooks_for_mut_file(self.post_retrieve_aspects.clone(), &mut fle)
|
||||
.map_err_into(SEK::PostHookExecuteError)
|
||||
.map_err_into(SEK::HookExecutionError)
|
||||
.and(Ok(fle))
|
||||
})
|
||||
.map_err_into(SEK::RetrieveCallError)
|
||||
.and(Ok(fle))
|
||||
}
|
||||
|
||||
/// Get an entry from the store if it exists.
|
||||
|
@ -596,6 +600,7 @@ impl Store {
|
|||
.map_err_into(SEK::DeleteCallError)
|
||||
}
|
||||
|
||||
{
|
||||
let mut entries = match self.entries.write() {
|
||||
Err(_) => return Err(SE::new(SEK::LockPoisoned, None))
|
||||
.map_err_into(SEK::DeleteCallError),
|
||||
|
@ -614,6 +619,7 @@ impl Store {
|
|||
return Err(SEK::FileError.into_error_with_cause(Box::new(e)))
|
||||
.map_err_into(SEK::DeleteCallError);
|
||||
}
|
||||
}
|
||||
|
||||
self.execute_hooks_for_id(self.post_delete_aspects.clone(), &id)
|
||||
.map_err_into(SEK::PostHookExecuteError)
|
||||
|
@ -680,6 +686,7 @@ impl Store {
|
|||
.map_err_into(SEK::MoveByIdCallError)
|
||||
}
|
||||
|
||||
{
|
||||
let hsmap = self.entries.write();
|
||||
if hsmap.is_err() {
|
||||
return Err(SE::new(SEK::LockPoisoned, None))
|
||||
|
@ -695,6 +702,8 @@ impl Store {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
self.execute_hooks_for_id(self.pre_move_aspects.clone(), &new_id)
|
||||
.map_err_into(SEK::PostHookExecuteError)
|
||||
.map_err_into(SEK::HookExecutionError)
|
||||
|
|
Loading…
Reference in a new issue