#region CPL License
/*
Nuclex Framework
Copyright (C) 2002-2009 Nuclex Development Labs
This library is free software; you can redistribute it and/or
modify it under the terms of the IBM Common Public License as
published by the IBM Corporation; either version 1.0 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
IBM Common Public License for more details.
You should have received a copy of the IBM Common Public
License along with this library
*/
#endregion
using System;
using System.Collections.Generic;
using System.Threading;
using System.Diagnostics;
using Nuclex.Support.Collections;
namespace Nuclex.Support.Scheduling {
/// Schedules actions for execution at a future point in time
partial class Scheduler {
#region class TimeSourceSingleton
///
/// Manages the singleton instance of the scheduler's default time source
///
private class TimeSourceSingleton {
///
/// Explicit static constructor to guarantee the singleton is initialized only
/// when a static member of this class is accessed.
///
static TimeSourceSingleton() { } // Do not remove!
/// The singleton instance of the default time source
internal static readonly ITimeSource Instance = Scheduler.CreateDefaultTimeSource();
}
#endregion // class TimeSourceSingleton
/// Returns the default time source for the scheduler
public static ITimeSource DefaultTimeSource {
get { return TimeSourceSingleton.Instance; }
}
/// Creates a new default time source for the scheduler
///
/// Whether the specialized windows time source should be used
///
/// The newly created time source
internal static ITimeSource CreateTimeSource(bool useWindowsTimeSource) {
if(useWindowsTimeSource) {
return new WindowsTimeSource();
} else {
return new GenericTimeSource();
}
}
/// Creates a new default time source for the scheduler
/// The newly created time source
internal static ITimeSource CreateDefaultTimeSource() {
return CreateTimeSource(WindowsTimeSource.Available);
}
}
} // namespace Nuclex.Support.Scheduling