Example #1
0
void 
TransDispatcher::processCleanup()
{
	if ( m_tickCleanup.Elapsed() < 1000 ) // every second
	{
		return;
	}

	m_tickCleanup.Reset();

	ActionMap::iterator i( m_actions.begin() );

	for ( ; i != m_actions.end(); ++i )
	{
		ActionList& lst = i->second;

		ActionList::iterator ai( lst.begin() );

		for ( ; ai != lst.end();  )
		{
			ActionPtr action = *ai;

			if ( action->IsFinished() )
			{
				ai = lst.erase( ai );
			}
			else
			{
				++ai;
			}
		}

		// keep empty list. not a big deal.
	}
}
Example #2
0
void 
TransDispatcher::Dispatch( Transaction* trans )
{
	ActionMap::iterator i( m_actions.find( trans->GetType() ) );

	if ( i != m_actions.end() )
	{
		ActionList& lst = i->second;

		ActionList::iterator ai( lst.begin() );

		for ( ; ai != lst.end(); ++ai )
		{
			ActionPtr action = *ai;

			K_ASSERT( action.Get() != 0 );

			if ( !action->IsFinished() )
			{
				action->Completed( trans );
			}
		}
	}
}