Exemple #1
0
	bool io_thread::pump_messages()
	{
		bool didWork = false;
		while (have_messages())
		{
			if (halted())
				return didWork;
			if (have_message_queue())
			{
				message_queue().get_message();
				message_queue().idle();
			}
			didWork = true;
		}
		return didWork;
	}
Exemple #2
0
Error usi_queue_message(USIMessage *message)
{
    CheckB(message->write_count + message->read_count > 0);

    /*
     * If there are any bytes to write, then place them directly into the registers.  The first
     * byte of the message is used as the initial offset location to write to in the registers.
     */
    if (message->write_count)
    {
	uint8	offset = message->buffer[0];
	uint8	count  = (message->write_count < (USI_REGISERS - offset) ?
			  message->write_count :
			  (USI_REGISERS - offset));

	CheckB(offset < USI_REGISERS);

	message->message.state = message_state_writing;

	for (uint8 i = 0; i < count; ++i)
	    _usi.registers[i + offset] = message->buffer[i + 1];
    }

    /*
     * If there are any bytes to be read, then queue the message up so that the interupt handler
     * will fill it with bytes that come from the master.
     */
    if (message->read_count)
	message_queue(&(message->message), &(_usi.device));
    else
	message->message.state = message_state_success;

    return success;
}
Exemple #3
0
	bool io_thread::process_events()
	{
		bool didWork = false;
		while (have_messages())
		{
			message_queue().get_message();
			didWork = true;
		}
		if (iEventProcessor)
			didWork = iEventProcessor() || didWork;
		return didWork;
	}
Exemple #4
0
	bool io_thread::do_io(bool aYieldIfNoWork)
	{
		if (iHalted)
			return false;
		bool didSome = false;
		didSome = (iTimerIoService.do_io(false) || didSome);
		didSome = (iNetworkingIoService.do_io(false) || didSome);
		didSome = (process_events() || didSome);
		if (!didSome && aYieldIfNoWork)
		{
			if (have_message_queue())
				message_queue().idle();
			sleep(1);
		}
		return didSome;
	}
Exemple #5
0
	bool io_thread::have_messages() const
	{
		return have_message_queue() && message_queue().have_message();
	}