void alert_manager::maybe_notify(alert* a, std::unique_lock<std::mutex>& lock)
	{
		if (m_alerts[m_generation].size() == 1)
		{
			lock.unlock();

			// we just posted to an empty queue. If anyone is waiting for
			// alerts, we need to notify them. Also (potentially) call the
			// user supplied m_notify callback to let the client wake up its
			// message loop to poll for alerts.
			if (m_notify) m_notify();

			// TODO: 2 keep a count of the number of threads waiting. Only if it's
			// > 0 notify them
			m_condition.notify_all();
		}
		else
		{
			lock.unlock();
		}

#ifndef TORRENT_DISABLE_EXTENSIONS
		for (auto& e : m_ses_extensions)
			e->on_alert(a);
#else
		TORRENT_UNUSED(a);
#endif
	}
Beispiel #2
0
//====================================================================
//====================================================================
void L2_cache :: process_client_reply (Coh_msg* reply)
{
    DBG_L2_CACHE_ID(cout,  "process_client_reply(), addr= " << hex << reply->addr << dec << endl);

    hash_entry* mshr_entry = mshr->get_entry(reply->addr);

    if(mshr_entry) { //this is a response to a request

	DBG_L2_CACHE(cout,  "    mshr found\n");

	ManagerInterface* manager = managers[mshr_map[mshr_entry->get_idx()]->get_idx()];
	manager->process_lower_client_reply(reply);

	if(manager->req_pending() == false) {
	    m_notify(manager);
	}
    }
    else { //no mshr exists for this reply; this could happen, for example, when a line is being evicted.
        //There must be a hash table entry.
	DBG_L2_CACHE(cout,  "    no mshr\n");

	hash_entry* hash_table_entry = my_table->get_entry(reply->addr);
	assert(hash_table_entry);

	ManagerInterface* manager = managers[hash_table_entry->get_idx()];
	manager->process_lower_client_reply(reply);

	if(manager->req_pending() == false) {
	    m_evict_notify(manager);
	}
    }
    delete reply;
}
Beispiel #3
0
	void alert_manager::maybe_notify(alert* a, mutex::scoped_lock& lock)
	{
#ifndef TORRENT_DISABLE_EXTENSIONS
		for (ses_extension_list_t::iterator i = m_ses_extensions.begin()
			, end(m_ses_extensions.end()); i != end; ++i)
		{
			(*i)->on_alert(a);
		}
#endif
		if (a->type() == save_resume_data_failed_alert::alert_type
			|| a->type() == save_resume_data_failed_alert::alert_type)
			++m_num_queued_resume;

		if (m_alerts[m_generation].size() == 1)
		{
			lock.unlock();

			// we just posted to an empty queue. If anyone is waiting for
			// alerts, we need to notify them. Also (potentially) call the
			// user supplied m_notify callback to let the client wake up its
			// message loop to poll for alerts.
			if (m_notify) m_notify();

			// TODO: 2 keep a count of the number of threads waiting. Only if it's
			// > 0 notify them
			m_condition.notify_all();
		}
	}
	void alert_manager::set_notify_function(boost::function<void()> const& fun)
	{
		std::unique_lock<std::mutex> lock(m_mutex);
		m_notify = fun;
		if (!m_alerts[m_generation].empty())
		{
			// never call a callback with the lock held!
			lock.unlock();
			if (m_notify) m_notify();
		}
	}
void TcpConnection::readHandle(const std::error_code &err)
{
    if (!err)
    {
        FileDataPtr pFileData(make_shared<FileData>(FileData::loads(m_readBuffer)));
        m_notify(pFileData);
        start();
    }
    else
    {
        close();
    }
}
Beispiel #6
0
 /**
  * @brief Add entry to the queue for FIFO processing
  *
  * Once a message is queued, the Message notification call back
  * function will be called if one has been provided
  *
  * @param entry Entry to add to the queue
  */
 void add( const Entry& entry )
 {
     m_queue.push_front( entry );
     if( m_notify )
         m_notify();
 }
Beispiel #7
0
InfEvent::~InfEvent()
{
    if( m_notify )
        m_notify( m_user_data );
}
Beispiel #8
0
InfTimer::~InfTimer()
{
    if( m_notify )
        m_notify( m_user_data );
}