Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1148)

Unified Diff: pkg/watcher/lib/src/directory_watcher.dart

Issue 18877005: Split up tests and add some heartbeats to try to make them not timeout. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix cut/paste error. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/watcher/test/directory_watcher_test.dart » ('j') | pkg/watcher/test/utils.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/watcher/lib/src/directory_watcher.dart
diff --git a/pkg/watcher/lib/src/directory_watcher.dart b/pkg/watcher/lib/src/directory_watcher.dart
index 0f297ba9045c3c3f539d48b68f82ef940c94e187..61bf6c52a2e77681160379813f7ecb4405d4c783 100644
--- a/pkg/watcher/lib/src/directory_watcher.dart
+++ b/pkg/watcher/lib/src/directory_watcher.dart
@@ -42,13 +42,24 @@ class DirectoryWatcher {
Future get ready => _ready.future;
Completer _ready = new Completer();
+ /// The amount of time the watcher pauses between successive polls of the
+ /// directory contents.
+ final Duration pollingDelay;
+
/// The previous status of the files in the directory.
///
/// Used to tell which files have been modified.
final _statuses = new Map<String, _FileStatus>();
/// Creates a new [DirectoryWatcher] monitoring [directory].
- DirectoryWatcher(this.directory) {
+ ///
+ /// If [pollingDelay] is passed, it specifies the amount of time the watcher
+ /// will pause between successive polls of the directory contents. Making
+ /// this shorter will give more immediate feedback at the expense of doing
+ /// more IO and higher CPU usage. Defaults to one second.
+ DirectoryWatcher(this.directory, {Duration pollingDelay})
+ : pollingDelay = pollingDelay != null ? pollingDelay :
+ new Duration(seconds: 1) {
_events = new StreamController<WatchEvent>.broadcast(onListen: () {
_state = _state.listen(this);
}, onCancel: () {
@@ -93,7 +104,7 @@ class DirectoryWatcher {
// restarting just so that we don't whale on the file system.
// TODO(rnystrom): Tune this and/or make it tunable?
if (_state.shouldNotify) {
- return new Future.delayed(new Duration(seconds: 1));
+ return new Future.delayed(pollingDelay);
}
}).then((_) {
// Make sure we haven't transitioned to a non-watching state during the
« no previous file with comments | « no previous file | pkg/watcher/test/directory_watcher_test.dart » ('j') | pkg/watcher/test/utils.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698