Moved polling code to libtorrent.

This commit is contained in:
Jari Sundell
2011-12-12 01:46:09 +09:00
parent 89213982d5
commit 6dfd2fe0cd
4 changed files with 6 additions and 100 deletions
+2 -26
View File
@@ -64,36 +64,12 @@ PollManagerKQueue::~PollManagerKQueue() {
void
PollManagerKQueue::poll(rak::timer timeout) {
// Add 1ms to ensure we don't idle loop due to the lack of
// resolution.
torrent::perform();
timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
ThreadBase::release_global_lock();
ThreadBase::entering_main_polling();
int status = static_cast<torrent::PollKQueue*>(m_poll)->poll((timeout.usec() + 999) / 1000);
ThreadBase::leaving_main_polling();
ThreadBase::acquire_global_lock();
if (status == -1)
return check_error();
torrent::perform();
static_cast<torrent::PollKQueue*>(m_poll)->perform();
static_cast<torrent::PollKQueue*>(m_poll)->do_poll();
}
void
PollManagerKQueue::poll_simple(rak::timer timeout) {
// Add 1ms to ensure we don't idle loop due to the lack of
// resolution.
timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
if (static_cast<torrent::PollKQueue*>(m_poll)->poll((timeout.usec() + 999) / 1000) == -1)
return check_error();
static_cast<torrent::PollKQueue*>(m_poll)->perform();
static_cast<torrent::PollKQueue*>(m_poll)->do_poll(torrent::Poll::poll_worker_thread);
}
}