virtual void end_frame()
	{
#ifdef SINGLE_THREADED
		if (!single_threaded())
		{
#endif
			while(alive_flag)
			{
				Glib::Mutex::Lock lock(mutex);
				Glib::TimeVal end_time;
				
				end_time.assign_current_time();
				end_time.add_microseconds(BOREDOM_TIMEOUT);
				
				if(!tile_queue.empty() && alive_flag)
				{
					if(cond_tile_queue_empty.timed_wait(mutex,end_time))
						break;
				}
				else
					break;
			}
#ifdef SINGLE_THREADED
		}
#endif
		Glib::Mutex::Lock lock(mutex);
		if(!alive_flag)
			return;
		return warm_target->end_frame();
	}
Esempio n. 2
0
void ThreadSleep::Sleep(unsigned int milliseconds)
{
	Glib::Mutex condMutex;
	Glib::Cond condition;
	condMutex.lock();
	Glib::TimeVal wait_period(milliseconds/1000,milliseconds%1000);
	Glib::TimeVal abs_time;
	abs_time.assign_current_time();
	abs_time.add(wait_period);
	condition.timed_wait(condMutex, abs_time);
	condMutex.unlock();
}
	virtual void end_frame()
	{
		{
			Glib::Mutex::Lock lock(mutex);

			if(!alive_flag)
				return;
			ready_next=false;

#ifdef GLIB_DISPATCHER_BROKEN
		ready_connection=Glib::signal_timeout().connect(
			sigc::bind_return(
				sigc::mem_fun(*this,&AsyncTarget_Scanline::frame_ready),
				false
			)
			,0
		);
#else
			frame_ready_signal();
#endif
		}

#ifdef SINGLE_THREADED
		if (single_threaded())
			signal_progress()();
		else
#endif
		{

			Glib::TimeVal end_time;

			end_time.assign_current_time();
			end_time.add_microseconds(BOREDOM_TIMEOUT);

			while(alive_flag && !ready_next)
			{
				Glib::Mutex::Lock lock(mutex);
				if(cond_frame_queue_empty.timed_wait(mutex, end_time))
					break;
			}
		}
	}