Moving thread code to libtorrent.

This commit is contained in:
Jari Sundell
2011-12-12 00:03:50 +09:00
parent 2d8036e3a8
commit 89213982d5
4 changed files with 12 additions and 34 deletions
+3 -16
View File
@@ -39,7 +39,7 @@
#include <pthread.h>
#include <sys/types.h>
#include <torrent/thread_base.h>
#include <torrent/utils/thread_base.h>
#include "rak/priority_queue_default.h"
#include "core/poll_manager.h"
@@ -50,25 +50,15 @@ struct thread_queue_hack;
struct thread_queue_hack;
class ThreadBase : public torrent::ThreadBase {
class ThreadBase : public torrent::thread_base {
public:
typedef rak::priority_queue_default priority_queue;
typedef void (*thread_base_func)(ThreadBase*);
typedef void* (*pthread_func)(void*);
enum state_type {
STATE_UNKNOWN,
STATE_INITIALIZED,
STATE_ACTIVE,
STATE_INACTIVE
};
ThreadBase();
virtual ~ThreadBase();
bool is_active() const { return m_state == STATE_ACTIVE; }
torrent::Poll* poll() { return m_pollManager->get_torrent_poll(); }
core::PollManager* poll_manager() { return m_pollManager; }
priority_queue& task_scheduler() { return m_taskScheduler; }
@@ -82,7 +72,7 @@ public:
void queue_item(thread_base_func newFunc);
static void* event_loop(ThreadBase* threadBase);
static void* event_loop(ThreadBase* thread);
// Only call this when global lock has been acquired, as it checks
// ThreadBase::is_main_polling() which is only guaranteed to remain
@@ -99,9 +89,6 @@ protected:
// TODO: Add thread name.
pthread_t m_thread;
state_type m_state;
// The timer needs to be sync'ed when updated...
core::PollManager* m_pollManager;