This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Fast file enumeration for Windows #25426
Merged
+2,209
−900
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
0fc66cd
Fast file enumeration for Windows
JeremyKuhne c4f14fa
Fix comment and method name for Unix
JeremyKuhne c0622df
Change BOOLEAN accessibility to internal and add missing unix PathInt…
JeremyKuhne 9b8c50e
Add issue for IsolatedStorage test on Unix
JeremyKuhne c8c411e
Change FindEnumerable to be IEnumerator directly.
JeremyKuhne d711235
Fix closure allocations and address other feedback.
JeremyKuhne 39ec45d
Use string.Create(), tweak enumerable disposal
JeremyKuhne a4a78d2
Add extended prefix for UAP to fix test failure.
JeremyKuhne 20f882f
Push initial handle creation up front and ensure handle closure for e…
JeremyKuhne 8099aad
Add missing CloseHandle file to Watcher and Ports projects.
JeremyKuhne f0d6ec1
Fix disposal gate
JeremyKuhne 7030750
Change to use RtlNtStatusToDosError (which underlies Lsa method we we…
JeremyKuhne a61ca3e
Fix outerloop test.
JeremyKuhne b7783fb
Tweak the comment and remove the ConditionalTheory as it isn't needed.
JeremyKuhne 2b5c49e
Align BOOLEAN with BOOL. Clean DosMatcher signature.
JeremyKuhne 9cbe9c4
Address feedback to make the enumerator threadsafe.
JeremyKuhne 6da9522
Add JKotas regression test and lock dispose
JeremyKuhne 1829bfb
Address various feedback.
JeremyKuhne 017394e
Tweak tests
JeremyKuhne 77eeccf
Expand length for ValueStringBuilder with nulls like StringBuilder do…
JeremyKuhne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,21 @@ public void FileEnumeratorIsThreadSafe() | |
for (int i = 0; i < 100; i++) | ||
File.Create(Path.Combine(directory, GetTestFileName())).Dispose(); | ||
|
||
new ThreadSafeRepro().Execute(directory); | ||
// We are really only trying to make sure we don't terminate the process. | ||
// Throwing IOException at this point to try and flush out other problems | ||
// like bad handles. Can narrow the throw if this isn't reliable. | ||
|
||
try | ||
{ | ||
new ThreadSafeRepro().Execute(directory); | ||
} | ||
catch (IOException) | ||
{ | ||
throw; | ||
} | ||
catch (Exception) | ||
{ | ||
} | ||
} | ||
|
||
class ThreadSafeRepro | ||
|
@@ -46,17 +60,24 @@ void Work() | |
if (x != null) | ||
Enumerate(x); | ||
} while (!token.IsCancellationRequested); | ||
token.ThrowIfCancellationRequested(); | ||
} | ||
|
||
new Task(Work, token).Start(); | ||
new Task(Work, token).Start(); | ||
for (int i = 0; i < 1000; i++) | ||
Task taskOne = Task.Run(action: Work); | ||
Task taskTwo = Task.Run(action: Work); | ||
|
||
try | ||
{ | ||
for (int i = 0; i < 1000; i++) | ||
{ | ||
_enumerator = Directory.EnumerateFiles(directory).GetEnumerator(); | ||
Enumerate(_enumerator); | ||
} | ||
} | ||
finally | ||
{ | ||
_enumerator = Directory.EnumerateFiles(directory).GetEnumerator(); | ||
Enumerate(_enumerator); | ||
source.Cancel(); | ||
Task.WaitAll(taskOne, taskTwo); | ||
} | ||
source.Cancel(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to do: Task t1 = Task.Run(Work);
Task t2 = Task.Run(Work);
...
source.Cancel();
Task.WaitAll(t1, t2); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just realized this as well. Thanks :) |
||
} | ||
} | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine. Another approach would be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update it as I'm updating VSB.