aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-01-26 11:47:15 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-01-26 11:47:15 -0500
commit63f3cf97dada179fc6e9e3a177504d3e7b36321c (patch)
treeb6810d34b9bc46d61e8565ec4fc0f0c178cd0b35 /MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
parent91416cb8a83eadde908e810afea981b6e4bed234 (diff)
add option to merge metadata and IBN paths
Diffstat (limited to 'MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs')
-rw-r--r--MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs72
1 files changed, 36 insertions, 36 deletions
diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
index 5e9038500..b09cb7105 100644
--- a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
+++ b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
@@ -108,13 +108,9 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
/// </summary>
private TaskResult _lastExecutionResult;
/// <summary>
- /// The _last execution resultinitialized
- /// </summary>
- private bool _lastExecutionResultinitialized;
- /// <summary>
/// The _last execution result sync lock
/// </summary>
- private object _lastExecutionResultSyncLock = new object();
+ private readonly object _lastExecutionResultSyncLock = new object();
/// <summary>
/// Gets the last execution result.
/// </summary>
@@ -123,38 +119,39 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
{
get
{
- LazyInitializer.EnsureInitialized(ref _lastExecutionResult, ref _lastExecutionResultinitialized, ref _lastExecutionResultSyncLock, () =>
+ if (_lastExecutionResult == null)
{
- var path = GetHistoryFilePath();
-
- try
- {
- return JsonSerializer.DeserializeFromFile<TaskResult>(path);
- }
- catch (DirectoryNotFoundException)
- {
- // File doesn't exist. No biggie
- return null;
- }
- catch (FileNotFoundException)
- {
- // File doesn't exist. No biggie
- return null;
- }
- catch (Exception ex)
+ lock (_lastExecutionResultSyncLock)
{
- Logger.ErrorException("Error deserializing {0}", ex, path);
- return null;
+ if (_lastExecutionResult == null)
+ {
+ var path = GetHistoryFilePath();
+
+ try
+ {
+ return JsonSerializer.DeserializeFromFile<TaskResult>(path);
+ }
+ catch (DirectoryNotFoundException)
+ {
+ // File doesn't exist. No biggie
+ }
+ catch (FileNotFoundException)
+ {
+ // File doesn't exist. No biggie
+ }
+ catch (Exception ex)
+ {
+ Logger.ErrorException("Error deserializing {0}", ex, path);
+ }
+ }
}
- });
+ }
return _lastExecutionResult;
}
private set
{
_lastExecutionResult = value;
-
- _lastExecutionResultinitialized = value != null;
}
}
@@ -227,13 +224,9 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
/// </summary>
private IEnumerable<ITaskTrigger> _triggers;
/// <summary>
- /// The _triggers initialized
- /// </summary>
- private bool _triggersInitialized;
- /// <summary>
/// The _triggers sync lock
/// </summary>
- private object _triggersSyncLock = new object();
+ private readonly object _triggersSyncLock = new object();
/// <summary>
/// Gets the triggers that define when the task will run
/// </summary>
@@ -243,7 +236,16 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
{
get
{
- LazyInitializer.EnsureInitialized(ref _triggers, ref _triggersInitialized, ref _triggersSyncLock, LoadTriggers);
+ if (_triggers == null)
+ {
+ lock (_triggersSyncLock)
+ {
+ if (_triggers == null)
+ {
+ _triggers = LoadTriggers();
+ }
+ }
+ }
return _triggers;
}
@@ -262,8 +264,6 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
_triggers = value.ToList();
- _triggersInitialized = true;
-
ReloadTriggerEvents(false);
SaveTriggers(_triggers);