mirror of
https://github.com/extrawurst/gitui.git
synced 2024-12-28 19:44:14 +03:00
fix problems with spawning too many async tasks underload (#196)
This commit is contained in:
parent
7e8df3ad28
commit
58a1719c98
@ -57,7 +57,7 @@ impl AsyncCommitFiles {
|
||||
|
||||
{
|
||||
let current = self.current.lock()?;
|
||||
if let Some(ref c) = *current {
|
||||
if let Some(c) = &*current {
|
||||
if c.0 == id {
|
||||
return Ok(());
|
||||
}
|
||||
@ -68,9 +68,9 @@ impl AsyncCommitFiles {
|
||||
let sender = self.sender.clone();
|
||||
let arc_pending = Arc::clone(&self.pending);
|
||||
|
||||
rayon_core::spawn(move || {
|
||||
arc_pending.fetch_add(1, Ordering::Relaxed);
|
||||
self.pending.fetch_add(1, Ordering::Relaxed);
|
||||
|
||||
rayon_core::spawn(move || {
|
||||
Self::fetch_helper(id, arc_current)
|
||||
.expect("failed to fetch");
|
||||
|
||||
@ -92,9 +92,15 @@ impl AsyncCommitFiles {
|
||||
) -> Result<()> {
|
||||
let res = sync::get_commit_files(CWD, id)?;
|
||||
|
||||
log::trace!(
|
||||
"get_commit_files: {} ({})",
|
||||
id.to_string(),
|
||||
res.len()
|
||||
);
|
||||
|
||||
{
|
||||
let mut last = arc_current.lock()?;
|
||||
*last = Some(Request(id, res));
|
||||
let mut current = arc_current.lock()?;
|
||||
*current = Some(Request(id, res));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -109,9 +109,10 @@ impl AsyncDiff {
|
||||
let arc_last = Arc::clone(&self.last);
|
||||
let sender = self.sender.clone();
|
||||
let arc_pending = Arc::clone(&self.pending);
|
||||
rayon_core::spawn(move || {
|
||||
arc_pending.fetch_add(1, Ordering::Relaxed);
|
||||
|
||||
self.pending.fetch_add(1, Ordering::Relaxed);
|
||||
|
||||
rayon_core::spawn(move || {
|
||||
let notify = AsyncDiff::get_diff_helper(
|
||||
params,
|
||||
arc_last,
|
||||
|
@ -117,16 +117,18 @@ impl AsyncLog {
|
||||
let arc_pending = Arc::clone(&self.pending);
|
||||
let arc_background = Arc::clone(&self.background);
|
||||
|
||||
self.pending.store(true, Ordering::Relaxed);
|
||||
|
||||
rayon_core::spawn(move || {
|
||||
scope_time!("async::revlog");
|
||||
|
||||
arc_pending.store(true, Ordering::Relaxed);
|
||||
AsyncLog::fetch_helper(
|
||||
arc_current,
|
||||
arc_background,
|
||||
&sender,
|
||||
)
|
||||
.expect("failed to fetch");
|
||||
|
||||
arc_pending.store(false, Ordering::Relaxed);
|
||||
|
||||
Self::notify(&sender);
|
||||
|
@ -116,9 +116,10 @@ impl AsyncStatus {
|
||||
let arc_pending = Arc::clone(&self.pending);
|
||||
let status_type = params.status_type;
|
||||
let include_untracked = params.include_untracked;
|
||||
rayon_core::spawn(move || {
|
||||
arc_pending.fetch_add(1, Ordering::Relaxed);
|
||||
|
||||
self.pending.fetch_add(1, Ordering::Relaxed);
|
||||
|
||||
rayon_core::spawn(move || {
|
||||
Self::fetch_helper(
|
||||
status_type,
|
||||
include_untracked,
|
||||
|
@ -74,9 +74,10 @@ impl AsyncTags {
|
||||
let arc_last = Arc::clone(&self.last);
|
||||
let sender = self.sender.clone();
|
||||
let arc_pending = Arc::clone(&self.pending);
|
||||
rayon_core::spawn(move || {
|
||||
arc_pending.fetch_add(1, Ordering::Relaxed);
|
||||
|
||||
self.pending.fetch_add(1, Ordering::Relaxed);
|
||||
|
||||
rayon_core::spawn(move || {
|
||||
let notify = AsyncTags::getter(arc_last)
|
||||
.expect("error getting tags");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user