#ifndef _TIMER_H
#define _TIMER_H

#include <MessageRunner.h>
#include <Locker.h>
#include "Gehnaphore.h"

namespace Wagner {

typedef void (*TimerHandler)(const BMessage* data);

class TimerLooper;

class Timer
{
public:
	Timer();
	virtual ~Timer();
	
	status_t Start(const BMessage* data, bigtime_t interval, int32 count = -1);
	status_t Start(TimerHandler handler, const BMessage* data,
				   bigtime_t interval, int32 count = -1);
	void Stop();
	
	virtual void TimerEvent(const BMessage* data);

	static void Shutdown();
	
private:
	BMessageRunner* fRunner;
	TimerHandler fHandler;
	Gehnaphore fLock;		// Protect fRunner
};

}

#endif
