Пример #1
0
void axEventManager::PushEvent(const axID& id,
                               const axEventId& evtId,
                               axMsg* msg)
{
    manager_mutex.lock();
    
    auto it = _event_fct_map.find(id);
    
    if(it != _event_fct_map.end())
    {
        // Pair of the first and last element of this id.
        auto range(it->second.equal_range(evtId));
        
        axCore* core = axApp::GetInstance()->GetCore();
        
        // Add every connected functions from this id to the event queue.
        for (axEventMultimapIterator i = range.first; i != range.second; ++i)
        {
            // Create a Copy of child params.
            axMsg* msg_copy = msg->GetCopy();

            // Add binded function to event queue.bn
            AddFunction(axBindedEvent(i->second, msg_copy));
            
            core->PushEventOnSystemQueue();
        }
    }
    
    manager_mutex.unlock();
    
    delete msg;
}
Пример #2
0
	void Manager::PushEvent(const ID& id, const Id& evtId, Msg* msg)
	{
		manager_mutex.lock();

		auto it = _event_fct_map.find(id);

		if (it == _event_fct_map.end()) {
			manager_mutex.unlock();
			if (msg) {
				delete msg;
			}
			return;
		}

		// Pair of the first and last element of this id.
		auto range(it->second.equal_range(evtId));

		if (range.first == it->second.end()) {
			manager_mutex.unlock();
			if (msg) {
				delete msg;
			}
			return;
		}

		// Add every connected functions from this id to the event queue.
		for (Multimap::iterator i = range.first; i != range.second; ++i) {
			// Create a Copy of child params
			// (this will create a new pointer with his own memory).
			Msg* msg_copy = msg->GetCopy();

			// Add binded function to event queue.
			AddFunction(axBindedEvent(i->second, msg_copy));

			if (_unblockMainThreadFct) {
				_unblockMainThreadFct();
			}
		}

		manager_mutex.unlock();
		if (msg) {
			delete msg;
		}
	}