package clock

import 

var _ interface {
	Scheduler
	NowScheduler
	TimerScheduler
	TickerScheduler
} = (*runtimeClock)(nil)

// systemClock is the Clock instance with runtimeClock Scheduler implementation.
var systemClock = Clock{newRuntimeClock()}

// System returns a clock provided by the host operating system.
func () *Clock {
	return &systemClock
}

// runtimeClock is a clock provided by the host operating system and Go runtime.
type runtimeClock struct{}

// newRuntimeClock returns a new runtimeClock instance that satisfies Scheduler.
func () Scheduler {
	return (*runtimeClock)(nil)
}

// Scheduler implements the Scheduler interface.
func ( *runtimeClock) ( time.Duration,  func( time.Time)) Event {
	return time.AfterFunc(, func() {
		(time.Now())
	})
}

// Now implements the NowScheduler interface.
func ( *runtimeClock) () time.Time {
	return time.Now()
}

// Timer implements the TimerScheduler interface.
func ( *runtimeClock) ( time.Duration) Timer {
	return runtimeTimer{time.NewTimer()}
}

// Ticker implements the TickerScheduler interface.
func ( *runtimeClock) ( time.Duration) Ticker {
	return runtimeTicker{time.NewTicker()}
}

// runtimeTimer is a Timer adapter for time.Timer type.
type runtimeTimer struct {
	*time.Timer
}

// C implements the Timer interface.
func ( runtimeTimer) () <-chan time.Time {
	return .Timer.C
}

// Reset implements the Timer interface.
func ( runtimeTimer) ( time.Duration) {
	_ = .Timer.Reset()
}

// runtimeTicker is a Ticker adapter for time.Ticker type.
type runtimeTicker struct {
	*time.Ticker
}

// C implements the Ticker interface.
func ( runtimeTicker) () <-chan time.Time {
	return .Ticker.C
}