#include <debug.h>
#include <err.h>
#include <kernel/Timer.h>
#include <kernel/Scheduler.h>
#include <os/Module.h>
#include <os/Thread.h>

using namespace OS;

namespace OS {
namespace Test {

	static handlerReturn timerCallbackPeriodic(Kernel::Timer *timer, void *data, time_t now)
	{
		dprintf("%s: timer %p, data %p, now %d\n", __PRETTY_FUNCTION__, timer, data, (int)now);

		return INT_NO_RESCHEDULE;
	}

	static int timersThreadRoutine()
	{
		Thread *t = Thread::GetCurrent();
		dprintf("timersThreadRoutine %p: start\n", t);

		Kernel::Timer *timer = new Kernel::Timer();

		timer->SetPeriodic(timerCallbackPeriodic, (void *)1, 1000);

		return 0;
	}

	static void timersTest()
	{
		Thread *t;
		t = new GenericThread(&timersThreadRoutine); t->SetPriority(Kernel::Scheduler::kHighestPriority); t->Start(false);
	}

	static status_t testInit(Module *)
	{
		TRACE_ENTRY;

		timersTest();

		return NO_ERROR;
	}

//	Module timersTestModule("Timers Test", Module::LEVEL_THREAD, &testInit);
}} // namespace OS::Test

