Skip to content

XDA-83 Automatically enumerate a directory where the 'too many changes' error occurs#535

Open
StephenCWills wants to merge 5 commits into
masterfrom
XDA-83
Open

XDA-83 Automatically enumerate a directory where the 'too many changes' error occurs#535
StephenCWills wants to merge 5 commits into
masterfrom
XDA-83

Conversation

@StephenCWills
Copy link
Copy Markdown
Member

  • The SynchronizedTask class is similar conceptually to the ISynchronizedOperation interface, but it is specifically designed to manage Task<T> objects so that those operations can be awaited to see when the operation is complete. Originally, I thought I'd need this for sequential enumeration strategy, but ultimately it seems I only needed it to implement cancellation.
  • Each TrackedDirectory now has a SynchronizedTask which allows the user to queue up a pending enumeration task if one is already running.
  • Cancelling enumeration on a TrackedDirectory will cancel both the currently running and pending enumerations, but any enumerations that queue up after that are not cancelled.
  • I reworked prioritization a bit. The processing thread always has highest priority, with file watcher's processing events taking priority over file enumeration's processing events. Below that, the file watcher thread has priority over the enumeration threads. This more granular prioritization helps to avoid starvation due to the sheer number of logical threads created by FileEnumerationStrategy.ParallelSubdirectories.
  • Thankfully, some of the async/await logic could be simplified, particulary in VisitFileAsync(). I also added some comments to make it clearer what the LogicalThread.Join() and LogicalThread.Yield() calls are used for.

@StephenCWills
Copy link
Copy Markdown
Member Author

It occurred to me last night that the enumeration task was awaiting the processing task, which meant that in most cases, enumeration wouldn't complete until all enumerated files had been processed by the FileProcessor. Instead, enumeration and processing should be more independent of each other. So I modified the logic to use processingThread.Push() instead of processingThread.Join().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant