diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-01-26 13:18:21 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-01-26 13:18:21 -0500 |
| commit | 82495f9ac31da23c7c1ea3b425e5effb45b51bb9 (patch) | |
| tree | 4a42d6471fb2f71b79b5b644a83f20c9923cc29f /MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs | |
| parent | 17cf1f3a6d60cc11f3fcb89edb7f8cd5bac29e24 (diff) | |
rework device concurrency
Diffstat (limited to 'MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs index 43b1e693c..9e4a45253 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs +++ b/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() |
