Removed deprecated PollManager files.

This commit is contained in:
Jari Sundell
2011-12-12 03:32:36 +09:00
parent 4d1f5dce67
commit ee859a6137
14 changed files with 31 additions and 514 deletions
-6
View File
@@ -26,12 +26,6 @@ libsub_core_a_SOURCES = \
manager.h \
poll_manager.cc \
poll_manager.h \
poll_manager_epoll.cc \
poll_manager_epoll.h \
poll_manager_kqueue.cc \
poll_manager_kqueue.h \
poll_manager_select.cc \
poll_manager_select.h \
range_map.h \
view.cc \
view.h \
+1 -3
View File
@@ -71,9 +71,7 @@
#include "download_store.h"
#include "http_queue.h"
#include "manager.h"
#include "poll_manager_epoll.h"
#include "poll_manager_kqueue.h"
#include "poll_manager_select.h"
#include "poll_manager.h"
#include "view.h"
namespace std { using namespace tr1; }
+24 -40
View File
@@ -39,71 +39,55 @@
#include <stdexcept>
#include <unistd.h>
#include <rak/error_number.h>
#include <torrent/poll_epoll.h>
#include <torrent/poll_kqueue.h>
#include <torrent/poll_select.h>
#include "globals.h"
#include "control.h"
#include "manager.h"
#include "poll_manager.h"
#include "poll_manager_epoll.h"
#include "poll_manager_kqueue.h"
#include "poll_manager_select.h"
namespace core {
PollManager::PollManager(torrent::Poll* poll) :
m_poll(poll) {
if (m_poll == NULL)
throw std::logic_error("PollManager::PollManager(...) received poll == NULL");
}
PollManager::~PollManager() {
delete m_poll;
}
PollManager*
PollManager::create_poll_manager() {
PollManager* pollManager = NULL;
torrent::Poll*
create_poll() {
Log* log = &control->core()->get_log_important();
const char* poll = getenv("RTORRENT_POLL");
const char* poll_name = getenv("RTORRENT_POLL");
int maxOpen = sysconf(_SC_OPEN_MAX);
if (poll != NULL) {
if (!strcmp(poll, "epoll"))
pollManager = PollManagerEPoll::create(maxOpen);
else if (!strcmp(poll, "kqueue"))
pollManager = PollManagerKQueue::create(maxOpen);
else if (!strcmp(poll, "select"))
pollManager = PollManagerSelect::create(maxOpen);
torrent::Poll* poll = NULL;
if (pollManager == NULL)
log->push_front(std::string("Cannot enable '") + poll + "' based polling.");
if (poll_name != NULL) {
if (!strcmp(poll_name, "epoll"))
poll = torrent::PollEPoll::create(maxOpen);
else if (!strcmp(poll_name, "kqueue"))
poll = torrent::PollKQueue::create(maxOpen);
else if (!strcmp(poll_name, "select"))
poll = torrent::PollSelect::create(maxOpen);
if (poll == NULL)
log->push_front(std::string("Cannot enable '") + poll_name + "' based polling.");
}
if (pollManager != NULL)
log->push_front(std::string("Using '") + poll + "' based polling.");
if (poll != NULL)
log->push_front(std::string("Using '") + poll_name + "' based polling.");
else if ((pollManager = PollManagerEPoll::create(maxOpen)) != NULL)
else if ((poll = torrent::PollEPoll::create(maxOpen)) != NULL)
log->push_front("Using 'epoll' based polling.");
else if ((pollManager = PollManagerKQueue::create(maxOpen)) != NULL)
else if ((poll = torrent::PollKQueue::create(maxOpen)) != NULL)
log->push_front("Using 'kqueue' based polling.");
else if ((pollManager = PollManagerSelect::create(maxOpen)) != NULL)
else if ((poll = torrent::PollSelect::create(maxOpen)) != NULL)
log->push_front("Using 'select' based polling.");
else
throw std::runtime_error("Could not create any PollManager.");
throw std::runtime_error("Could not create any Poll object.");
return pollManager;
}
void
PollManager::check_error() {
if (rak::error_number::current().value() != rak::error_number::e_intr)
throw std::runtime_error("Poll::work(): " + std::string(rak::error_number::current().c_str()));
return poll;
}
}
+1 -27
View File
@@ -45,33 +45,7 @@
namespace core {
// CurlStack really should be somewhere else, but that won't happen
// until they add an epoll friendly API.
class PollManager {
public:
typedef sigc::signal0<void> Signal;
PollManager(torrent::Poll* poll);
virtual ~PollManager();
unsigned int get_open_max() const { return m_poll->open_max(); }
torrent::Poll* get_torrent_poll() { return m_poll; }
virtual void poll(rak::timer timeout) = 0;
virtual void poll_simple(rak::timer timeout) = 0;
static PollManager* create_poll_manager();
protected:
PollManager(const PollManager&);
void operator = (const PollManager&);
void check_error();
torrent::Poll* m_poll;
};
torrent::Poll* create_poll();
}
-74
View File
@@ -1,74 +0,0 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2011, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#include "config.h"
#include <cstring>
#include <stdexcept>
#include <unistd.h>
#include <sys/time.h>
#include <torrent/poll_epoll.h>
#include <torrent/torrent.h>
#include "poll_manager_epoll.h"
#include "thread_base.h"
namespace core {
PollManagerEPoll*
PollManagerEPoll::create(int maxOpenSockets) {
torrent::PollEPoll* p = torrent::PollEPoll::create(maxOpenSockets);
if (p == NULL)
return NULL;
else
return new PollManagerEPoll(p);
}
PollManagerEPoll::~PollManagerEPoll() {
}
void
PollManagerEPoll::poll(rak::timer timeout) {
static_cast<torrent::PollEPoll*>(m_poll)->do_poll(timeout.usec());
}
void
PollManagerEPoll::poll_simple(rak::timer timeout) {
static_cast<torrent::PollEPoll*>(m_poll)->do_poll(timeout.usec(), torrent::Poll::poll_worker_thread);
}
}
-64
View File
@@ -1,64 +0,0 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2011, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#ifndef RTORRENT_CORE_POLL_MANAGER_EPOLL_H
#define RTORRENT_CORE_POLL_MANAGER_EPOLL_H
#include "poll_manager.h"
namespace torrent {
class PollEPoll;
}
namespace core {
class PollManagerEPoll : public PollManager {
public:
static PollManagerEPoll* create(int maxOpenSockets);
~PollManagerEPoll();
torrent::Poll* get_torrent_poll();
void poll(rak::timer timeout);
void poll_simple(rak::timer timeout);
private:
PollManagerEPoll(torrent::Poll* p) : PollManager(p) {}
};
}
#endif
-75
View File
@@ -1,75 +0,0 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2011, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#include "config.h"
#include <cstring>
#include <stdexcept>
#include <unistd.h>
#include <sys/time.h>
#include <torrent/exceptions.h>
#include <torrent/poll_kqueue.h>
#include <torrent/torrent.h>
#include "poll_manager_kqueue.h"
#include "thread_base.h"
namespace core {
PollManagerKQueue*
PollManagerKQueue::create(int maxOpenSockets) {
torrent::PollKQueue* p = torrent::PollKQueue::create(maxOpenSockets);
if (p == NULL)
return NULL;
else
return new PollManagerKQueue(p);
}
PollManagerKQueue::~PollManagerKQueue() {
}
void
PollManagerKQueue::poll(rak::timer timeout) {
static_cast<torrent::PollKQueue*>(m_poll)->do_poll(timeout.usec());
}
void
PollManagerKQueue::poll_simple(rak::timer timeout) {
static_cast<torrent::PollKQueue*>(m_poll)->do_poll(timeout.usec(), torrent::Poll::poll_worker_thread);
}
}
-64
View File
@@ -1,64 +0,0 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2011, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#ifndef RTORRENT_CORE_POLL_MANAGER_KQUEUE_H
#define RTORRENT_CORE_POLL_MANAGER_KQUEUE_H
#include "poll_manager.h"
namespace torrent {
class PollKQueue;
}
namespace core {
class PollManagerKQueue : public PollManager {
public:
static PollManagerKQueue* create(int maxOpenSockets);
~PollManagerKQueue();
torrent::Poll* get_torrent_poll();
void poll(rak::timer timeout);
void poll_simple(rak::timer timeout);
private:
PollManagerKQueue(torrent::Poll* p) : PollManager(p) {}
};
}
#endif
-86
View File
@@ -1,86 +0,0 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2011, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#include "config.h"
#include <cstring>
#include <stdexcept>
#include <unistd.h>
#include <sys/time.h>
#include <rak/allocators.h>
#include <torrent/exceptions.h>
#include <torrent/poll_select.h>
#include <torrent/torrent.h>
#include "poll_manager_select.h"
#include "thread_base.h"
namespace core {
PollManagerSelect::PollManagerSelect(torrent::Poll* p) : PollManager(p) {
#if defined USE_VARIABLE_FDSET
m_setSize = (m_poll->open_max() + 7) / 8;
#else
#error Only variable fdset supported atm.
#endif
}
PollManagerSelect*
PollManagerSelect::create(int maxOpenSockets) {
torrent::PollSelect* p = torrent::PollSelect::create(maxOpenSockets);
if (p == NULL)
return NULL;
return new PollManagerSelect(p);
}
PollManagerSelect::~PollManagerSelect() {
}
void
PollManagerSelect::poll(rak::timer timeout) {
// timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
static_cast<torrent::PollSelect*>(m_poll)->do_poll(timeout.usec());
}
void
PollManagerSelect::poll_simple(rak::timer timeout) {
static_cast<torrent::PollSelect*>(m_poll)->do_poll(timeout.usec(), torrent::PollSelect::poll_worker_thread);
}
}
-64
View File
@@ -1,64 +0,0 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005-2011, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations
// including the two.
//
// You must obey the GNU General Public License in all respects for
// all of the code used other than OpenSSL. If you modify file(s)
// with this exception, you may extend this exception to your version
// of the file(s), but you are not obligated to do so. If you do not
// wish to do so, delete this exception statement from your version.
// If you delete this exception statement from all source files in the
// program, then also delete it here.
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#ifndef RTORRENT_CORE_POLL_MANAGER_SELECT_H
#define RTORRENT_CORE_POLL_MANAGER_SELECT_H
#include "poll_manager.h"
namespace torrent {
class PollSelect;
}
namespace core {
class lt_cacheline_aligned PollManagerSelect : public PollManager {
public:
static PollManagerSelect* create(int maxOpenSockets);
~PollManagerSelect();
void poll(rak::timer timeout);
void poll_simple(rak::timer timeout);
private:
PollManagerSelect(torrent::Poll* p);
unsigned int m_setSize;
};
}
#endif
+2 -4
View File
@@ -107,15 +107,13 @@ public:
void throw_shutdown_exception() { throw torrent::shutdown_exception(); }
ThreadBase::ThreadBase() :
m_pollManager(NULL) {
ThreadBase::ThreadBase() {
m_taskShutdown.set_slot(rak::ptr_fn(&throw_shutdown_exception));
m_threadQueue = new thread_queue_hack;
}
ThreadBase::~ThreadBase() {
delete m_pollManager;
delete m_threadQueue;
}
@@ -155,7 +153,7 @@ ThreadBase::event_loop(ThreadBase* thread) {
rak::priority_queue_perform(&thread->m_taskScheduler, cachedTime);
thread->m_pollManager->poll_simple(thread->client_next_timeout());
thread->m_poll->do_poll(thread->client_next_timeout().usec(), torrent::Poll::poll_worker_thread);
}
} catch (torrent::shutdown_exception& e) {
-1
View File
@@ -90,7 +90,6 @@ protected:
// The timer needs to be sync'ed when updated...
core::PollManager* m_pollManager;
rak::priority_queue_default m_taskScheduler;
rak::priority_item m_taskShutdown;
+2 -3
View File
@@ -49,9 +49,8 @@ ThreadMain::init_thread() {
// The main thread always holds the lock while running.
acquire_global_lock();
m_pollManager = core::PollManager::create_poll_manager();
m_pollManager->get_torrent_poll()->set_flags(torrent::Poll::flag_waive_global_lock);
m_poll = m_pollManager->get_torrent_poll();
m_poll = core::create_poll();
m_poll->set_flags(torrent::Poll::flag_waive_global_lock);
m_state = STATE_INITIALIZED;
m_thread = pthread_self();
+1 -3
View File
@@ -62,9 +62,7 @@ ThreadWorker::~ThreadWorker() {
void
ThreadWorker::init_thread() {
m_pollManager = core::PollManager::create_poll_manager();
m_poll = m_pollManager->get_torrent_poll();
m_poll = core::create_poll();
m_state = STATE_INITIALIZED;
}