-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance of watcher, operations and props loading (#6028)
- Loading branch information
Showing
11 changed files
with
408 additions
and
412 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Files.Helpers | ||
{ | ||
public class AsyncManualResetEvent | ||
{ | ||
private volatile TaskCompletionSource<bool> m_tcs = new TaskCompletionSource<bool>(); | ||
|
||
public async Task WaitAsync(CancellationToken cancellationToken = default) | ||
{ | ||
var tcs = m_tcs; | ||
var cancelTcs = new TaskCompletionSource<bool>(); | ||
|
||
cancellationToken.Register( | ||
s => ((TaskCompletionSource<bool>)s).TrySetCanceled(), cancelTcs); | ||
|
||
await await Task.WhenAny(tcs.Task, cancelTcs.Task); | ||
} | ||
|
||
private async Task<bool> Delay(int milliseconds) | ||
{ | ||
await Task.Delay(milliseconds); | ||
return false; | ||
} | ||
|
||
public async Task<bool> WaitAsync(int milliseconds, CancellationToken cancellationToken = default) | ||
{ | ||
var tcs = m_tcs; | ||
var cancelTcs = new TaskCompletionSource<bool>(); | ||
|
||
cancellationToken.Register( | ||
s => ((TaskCompletionSource<bool>)s).TrySetCanceled(), cancelTcs); | ||
|
||
return await await Task.WhenAny(tcs.Task, cancelTcs.Task, Delay(milliseconds)); | ||
} | ||
|
||
public void Set() | ||
{ | ||
var tcs = m_tcs; | ||
Task.Factory.StartNew(s => ((TaskCompletionSource<bool>)s).TrySetResult(true), | ||
tcs, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default); | ||
tcs.Task.Wait(); | ||
} | ||
|
||
public void Reset() | ||
{ | ||
while (true) | ||
{ | ||
var tcs = m_tcs; | ||
if (!tcs.Task.IsCompleted || | ||
Interlocked.CompareExchange(ref m_tcs, new TaskCompletionSource<bool>(), tcs) == tcs) | ||
return; | ||
} | ||
} | ||
} | ||
} |
This file contains 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
128 changes: 0 additions & 128 deletions
128
Files/Helpers/FileListCache/PersistentSQLiteCacheAdapter.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.