瀏覽代碼

rework device concurrency

Luke Pulverenti 9 年之前
父節點
當前提交
82495f9ac3
共有 1 個文件被更改,包括 5 次插入8 次删除
  1. 5 8
      MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs

+ 5 - 8
MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs

@@ -25,7 +25,7 @@ namespace MediaBrowser.Server.Implementations.Devices
         private readonly ILogger _logger;
         private readonly IFileSystem _fileSystem;
 
-        private ConcurrentBag<DeviceInfo> _devices;
+        private List<DeviceInfo> _devices;
 
         public DeviceRepository(IApplicationPaths appPaths, IJsonSerializer json, ILogger logger, IFileSystem fileSystem)
         {
@@ -93,17 +93,14 @@ namespace MediaBrowser.Server.Implementations.Devices
 
         public IEnumerable<DeviceInfo> GetDevices()
         {
-            if (_devices == null)
+            lock (_syncLock)
             {
-                lock (_syncLock)
+                if (_devices == null)
                 {
-                    if (_devices == null)
-                    {
-                        _devices = new ConcurrentBag<DeviceInfo>(LoadDevices());
-                    }
+                    _devices = LoadDevices().ToList();
                 }
+                return _devices.ToList();
             }
-            return _devices.ToList();
         }
 
         private IEnumerable<DeviceInfo> LoadDevices()