/**********************************************************************
 
	Copyright (C) 2003-2004
	Hirohisa MORI <joshua@nichibun.ac.jp>
	Tomoki SEKIYAMA <sekiyama@yahoo.co.jp>
 
	This program is free software; you can redistribute it 
	and/or modify it under the terms of the GLOBALBASE 
	Library General Public License (G-LGPL) as published by 

	http://www.globalbase.org/
 
	This program 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.

**********************************************************************/



#include <LPeriodical.h>

class CYieldRepeater : public LPeriodical
{
  public:
	static UInt32	curTick;

	CYieldRepeater(SInt32 quantum = -1);
	virtual void	SpendTime( const EventRecord& inMacEvent );

	static void GetMouseEvent()
	{
		*sExitLoop = true;
		LThread::Yield(LThread::GetMainThread());
	}

	static CYieldRepeater *	theRepeater() { return theYCR; }
	
  protected:
	SInt32				mQuantum;
	UInt32				mNextTicks;
	static bool			*sExitLoop;
	static int			sGetMouseEvent;
	static LThread *		sGoBack;
	static CYieldRepeater *		theYCR;
	
	friend class LThread;
};
