diff options
Diffstat (limited to 'mcs/class/System/System.IO')
-rw-r--r-- | mcs/class/System/System.IO/DefaultWatcher.cs | 13 | ||||
-rw-r--r-- | mcs/class/System/System.IO/FAMWatcher.cs | 37 | ||||
-rw-r--r-- | mcs/class/System/System.IO/FileSystemWatcher.cs | 3 | ||||
-rw-r--r-- | mcs/class/System/System.IO/KeventWatcher.cs | 39 | ||||
-rw-r--r-- | mcs/class/System/System.IO/WindowsWatcher.cs | 1 |
5 files changed, 46 insertions, 47 deletions
diff --git a/mcs/class/System/System.IO/DefaultWatcher.cs b/mcs/class/System/System.IO/DefaultWatcher.cs index bc4bca41edc..1a02cdb1b62 100644 --- a/mcs/class/System/System.IO/DefaultWatcher.cs +++ b/mcs/class/System/System.IO/DefaultWatcher.cs @@ -63,18 +63,17 @@ namespace System.IO { { } + // Locked by caller public static bool GetInstance (out IFileWatcher watcher) { - lock (typeof (DefaultWatcher)) { - if (instance != null) { - watcher = instance; - return true; - } - - instance = new DefaultWatcher (); + if (instance != null) { watcher = instance; return true; } + + instance = new DefaultWatcher (); + watcher = instance; + return true; } public void StartDispatching (FileSystemWatcher fsw) diff --git a/mcs/class/System/System.IO/FAMWatcher.cs b/mcs/class/System/System.IO/FAMWatcher.cs index c6d1a61aad8..47a5595e9b0 100644 --- a/mcs/class/System/System.IO/FAMWatcher.cs +++ b/mcs/class/System/System.IO/FAMWatcher.cs @@ -82,31 +82,30 @@ namespace System.IO { { } + // Locked by caller public static bool GetInstance (out IFileWatcher watcher) { - lock (typeof (FAMWatcher)) { - if (failed == true) { - watcher = null; - return false; - } - - if (instance != null) { - watcher = instance; - return true; - } - - watches = Hashtable.Synchronized (new Hashtable ()); - requests = Hashtable.Synchronized (new Hashtable ()); - if (FAMOpen (out conn) == -1) { - failed = true; - watcher = null; - return false; - } + if (failed == true) { + watcher = null; + return false; + } - instance = new FAMWatcher (); + if (instance != null) { watcher = instance; return true; } + + watches = Hashtable.Synchronized (new Hashtable ()); + requests = Hashtable.Synchronized (new Hashtable ()); + if (FAMOpen (out conn) == -1) { + failed = true; + watcher = null; + return false; + } + + instance = new FAMWatcher (); + watcher = instance; + return true; } public void StartDispatching (FileSystemWatcher fsw) diff --git a/mcs/class/System/System.IO/FileSystemWatcher.cs b/mcs/class/System/System.IO/FileSystemWatcher.cs index e4018da1210..d3d421ccc21 100644 --- a/mcs/class/System/System.IO/FileSystemWatcher.cs +++ b/mcs/class/System/System.IO/FileSystemWatcher.cs @@ -57,6 +57,7 @@ namespace System.IO { bool disposed; string mangledFilter; static IFileWatcher watcher; + static object lockobj = new object (); #endregion // Fields @@ -104,7 +105,7 @@ namespace System.IO { void InitWatcher () { - lock (typeof (FileSystemWatcher)) { + lock (lockobj) { if (watcher != null) return; diff --git a/mcs/class/System/System.IO/KeventWatcher.cs b/mcs/class/System/System.IO/KeventWatcher.cs index 803629effcd..d26c30e22f7 100644 --- a/mcs/class/System/System.IO/KeventWatcher.cs +++ b/mcs/class/System/System.IO/KeventWatcher.cs @@ -93,32 +93,31 @@ namespace System.IO { { } + // Locked by caller public static bool GetInstance (out IFileWatcher watcher) { - lock (typeof (KeventWatcher)) { - if (failed == true) { - watcher = null; - return false; - } - - if (instance != null) { - watcher = instance; - return true; - } - - watches = Hashtable.Synchronized (new Hashtable ()); - requests = Hashtable.Synchronized (new Hashtable ()); - conn = kqueue(); - if (conn == -1) { - failed = true; - watcher = null; - return false; - } + if (failed == true) { + watcher = null; + return false; + } - instance = new KeventWatcher (); + if (instance != null) { watcher = instance; return true; } + + watches = Hashtable.Synchronized (new Hashtable ()); + requests = Hashtable.Synchronized (new Hashtable ()); + conn = kqueue(); + if (conn == -1) { + failed = true; + watcher = null; + return false; + } + + instance = new KeventWatcher (); + watcher = instance; + return true; } public void StartDispatching (FileSystemWatcher fsw) diff --git a/mcs/class/System/System.IO/WindowsWatcher.cs b/mcs/class/System/System.IO/WindowsWatcher.cs index e7b53592e12..dc5e848f13d 100644 --- a/mcs/class/System/System.IO/WindowsWatcher.cs +++ b/mcs/class/System/System.IO/WindowsWatcher.cs @@ -35,6 +35,7 @@ namespace System.IO { { } + // Locked by caller public static bool GetInstance (out IFileWatcher watcher) { throw new NotSupportedException (); |