Moved main thread object to libtorrent.

This commit is contained in:
rakshasa
2012-02-12 21:58:16 +09:00
parent 9ad22ab8ff
commit 47125b9c38
9 changed files with 36 additions and 153 deletions
+8 -7
View File
@@ -41,6 +41,7 @@
#include <torrent/poll.h>
#include <torrent/exceptions.h>
#include <torrent/utils/thread_base.h>
#include "control.h"
@@ -69,22 +70,22 @@ CurlSocket::receive_socket(void* easy_handle, curl_socket_t fd, int what, void*
if (socket == NULL) {
socket = stack->new_socket(fd);
main_thread->poll()->open(socket);
torrent::main_thread()->poll()->open(socket);
// No interface for libcurl to signal when it's interested in error events.
// Assume that hence it must always be interested in them.
main_thread->poll()->insert_error(socket);
torrent::main_thread()->poll()->insert_error(socket);
}
if (what == CURL_POLL_NONE || what == CURL_POLL_OUT)
main_thread->poll()->remove_read(socket);
torrent::main_thread()->poll()->remove_read(socket);
else
main_thread->poll()->insert_read(socket);
torrent::main_thread()->poll()->insert_read(socket);
if (what == CURL_POLL_NONE || what == CURL_POLL_IN)
main_thread->poll()->remove_write(socket);
torrent::main_thread()->poll()->remove_write(socket);
else
main_thread->poll()->insert_write(socket);
torrent::main_thread()->poll()->insert_write(socket);
return 0;
}
@@ -99,7 +100,7 @@ CurlSocket::close() {
if (m_fileDesc == -1)
throw torrent::internal_error("CurlSocket::close() m_fileDesc == -1.");
main_thread->poll()->closed(this);
torrent::main_thread()->poll()->closed(this);
m_fileDesc = -1;
}