update locking

This commit is contained in:
Luke Pulverenti 2016-01-31 19:57:40 -05:00
parent 7ac682f06c
commit 0297d8f7d3
5 changed files with 14 additions and 10 deletions

View File

@ -233,7 +233,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
/// <summary>
/// The _triggers
/// </summary>
private IEnumerable<ITaskTrigger> _triggers;
private volatile List<ITaskTrigger> _triggers;
/// <summary>
/// The _triggers sync lock
/// </summary>
@ -532,7 +532,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
/// Loads the triggers.
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
private IEnumerable<ITaskTrigger> LoadTriggers()
private List<ITaskTrigger> LoadTriggers()
{
try
{
@ -543,12 +543,12 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
catch (FileNotFoundException)
{
// File doesn't exist. No biggie. Return defaults.
return ScheduledTask.GetDefaultTriggers();
return ScheduledTask.GetDefaultTriggers().ToList();
}
catch (DirectoryNotFoundException)
{
// File doesn't exist. No biggie. Return defaults.
return ScheduledTask.GetDefaultTriggers();
return ScheduledTask.GetDefaultTriggers().ToList();
}
}

View File

@ -109,7 +109,7 @@ namespace MediaBrowser.Controller.Entities
/// <value>The last activity date.</value>
public DateTime? LastActivityDate { get; set; }
private UserConfiguration _config;
private volatile UserConfiguration _config;
private readonly object _configSyncLock = new object();
[IgnoreDataMember]
public UserConfiguration Configuration
@ -132,7 +132,7 @@ namespace MediaBrowser.Controller.Entities
set { _config = value; }
}
private UserPolicy _policy;
private volatile UserPolicy _policy;
private readonly object _policySyncLock = new object();
[IgnoreDataMember]
public UserPolicy Policy

View File

@ -222,7 +222,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <summary>
/// The _root folder
/// </summary>
private AggregateFolder _rootFolder;
private volatile AggregateFolder _rootFolder;
/// <summary>
/// The _root folder sync lock
/// </summary>
@ -743,7 +743,7 @@ namespace MediaBrowser.Server.Implementations.Library
return rootFolder;
}
private UserRootFolder _userRootFolder;
private volatile UserRootFolder _userRootFolder;
private readonly object _syncLock = new object();
public Folder GetUserRootFolder()
{

View File

@ -239,7 +239,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
public Task CancelSeriesTimerAsync(string timerId, CancellationToken cancellationToken)
{
var timers = _timerProvider.GetAll().Where(i => string.Equals(i.SeriesTimerId, timerId, StringComparison.OrdinalIgnoreCase));
var timers = _timerProvider
.GetAll()
.Where(i => string.Equals(i.SeriesTimerId, timerId, StringComparison.OrdinalIgnoreCase))
.ToList();
foreach (var timer in timers)
{
CancelTimerInternal(timer.Id);

View File

@ -13,7 +13,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
where T : class
{
private readonly object _fileDataLock = new object();
private List<T> _items;
private volatile List<T> _items;
private readonly IJsonSerializer _jsonSerializer;
protected readonly ILogger Logger;
private readonly string _dataPath;