C++11 fixes.

This commit is contained in:
Jari Sundell
2011-12-27 16:45:19 +09:00
parent f51b280cbf
commit 0626dcf783
14 changed files with 32 additions and 32 deletions
+11 -11
View File
@@ -47,7 +47,7 @@ namespace rak {
class priority_item { class priority_item {
public: public:
typedef std::tr1::function<void ()> slot_void; typedef std::tr1::function<void (void)> slot_void;
priority_item() {} priority_item() {}
~priority_item() { ~priority_item() {
@@ -55,19 +55,19 @@ public:
throw std::logic_error("priority_item::~priority_item() called on a queued item."); throw std::logic_error("priority_item::~priority_item() called on a queued item.");
m_time = timer(); m_time = timer();
m_slot = slot_void();
} }
bool is_valid() const { return !!m_slot; } bool is_valid() const { return (bool)m_slot; }
bool is_queued() const { return m_time != timer(); } bool is_queued() const { return m_time != timer(); }
void call() { m_slot(); } slot_void& slot() { return m_slot; }
void set_slot(const slot_void& s) { m_slot = s; }
const timer& time() const { return m_time; }
void clear_time() { m_time = timer(); }
void set_time(const timer& t) { m_time = t; }
bool compare(const timer& t) const { return m_time > t; } const timer& time() const { return m_time; }
void clear_time() { m_time = timer(); }
void set_time(const timer& t) { m_time = t; }
bool compare(const timer& t) const { return m_time > t; }
private: private:
priority_item(const priority_item&); priority_item(const priority_item&);
@@ -94,7 +94,7 @@ priority_queue_perform(priority_queue_default* queue, timer t) {
queue->pop(); queue->pop();
v->clear_time(); v->clear_time();
v->call(); v->slot()();
} }
} }
+1 -1
View File
@@ -77,7 +77,7 @@ Control::Control() :
m_inputStdin->slot_pressed(sigc::mem_fun(m_input, &input::Manager::pressed)); m_inputStdin->slot_pressed(sigc::mem_fun(m_input, &input::Manager::pressed));
m_taskShutdown.set_slot(std::tr1::bind(&Control::handle_shutdown, this)); m_taskShutdown.slot() = std::tr1::bind(&Control::handle_shutdown, this);
m_commandScheduler->set_slot_error_message(rak::mem_fn(m_core, &core::Manager::push_log_std)); m_commandScheduler->set_slot_error_message(rak::mem_fn(m_core, &core::Manager::push_log_std));
} }
+1 -1
View File
@@ -82,7 +82,7 @@ CurlGet::start() {
// Normally libcurl should handle the timeout. But sometimes that doesn't // Normally libcurl should handle the timeout. But sometimes that doesn't
// work right so we do a fallback timeout that just aborts the transfer. // work right so we do a fallback timeout that just aborts the transfer.
m_taskTimeout.set_slot(std::tr1::bind(&CurlGet::receive_timeout, this)); m_taskTimeout.slot() = std::tr1::bind(&CurlGet::receive_timeout, this);
priority_queue_erase(&taskScheduler, &m_taskTimeout); priority_queue_erase(&taskScheduler, &m_taskTimeout);
priority_queue_insert(&taskScheduler, &m_taskTimeout, cachedTime + rak::timer::from_seconds(m_timeout + 5)); priority_queue_insert(&taskScheduler, &m_taskTimeout, cachedTime + rak::timer::from_seconds(m_timeout + 5));
} }
+1 -1
View File
@@ -55,7 +55,7 @@ CurlStack::CurlStack() :
m_ssl_verify_peer(true), m_ssl_verify_peer(true),
m_dns_timeout(60) { m_dns_timeout(60) {
m_taskTimeout.set_slot(std::tr1::bind(&CurlStack::receive_timeout, this)); m_taskTimeout.slot() = std::tr1::bind(&CurlStack::receive_timeout, this);
#if (LIBCURL_VERSION_NUM >= 0x071000) #if (LIBCURL_VERSION_NUM >= 0x071000)
curl_multi_setopt((CURLM*)m_handle, CURLMOPT_TIMERDATA, this); curl_multi_setopt((CURLM*)m_handle, CURLMOPT_TIMERDATA, this);
+2 -2
View File
@@ -114,7 +114,7 @@ DhtManager::start_dht() {
torrent::dht_manager()->start(port); torrent::dht_manager()->start(port);
torrent::dht_manager()->reset_statistics(); torrent::dht_manager()->reset_statistics();
m_updateTimeout.set_slot(std::tr1::bind(&DhtManager::update, this)); m_updateTimeout.slot() = std::tr1::bind(&DhtManager::update, this);
priority_queue_insert(&taskScheduler, &m_updateTimeout, (cachedTime + rak::timer::from_seconds(60)).round_seconds()); priority_queue_insert(&taskScheduler, &m_updateTimeout, (cachedTime + rak::timer::from_seconds(60)).round_seconds());
m_dhtPrevCycle = 0; m_dhtPrevCycle = 0;
@@ -197,7 +197,7 @@ DhtManager::update() {
break; break;
if (itr == end) { if (itr == end) {
m_stopTimeout.set_slot(std::tr1::bind(&DhtManager::stop_dht, this)); m_stopTimeout.slot() = std::tr1::bind(&DhtManager::stop_dht, this);
priority_queue_insert(&taskScheduler, &m_stopTimeout, (cachedTime + rak::timer::from_seconds(15 * 60)).round_seconds()); priority_queue_insert(&taskScheduler, &m_stopTimeout, (cachedTime + rak::timer::from_seconds(15 * 60)).round_seconds());
} }
} }
+2 -2
View File
@@ -106,8 +106,8 @@ DownloadFactory::DownloadFactory(Manager* m) :
m_printLog(true), m_printLog(true),
m_isFile(false) { m_isFile(false) {
m_taskLoad.set_slot(std::tr1::bind(&DownloadFactory::receive_load, this)); m_taskLoad.slot() = std::tr1::bind(&DownloadFactory::receive_load, this);
m_taskCommit.set_slot(std::tr1::bind(&DownloadFactory::receive_commit, this)); m_taskCommit.slot() = std::tr1::bind(&DownloadFactory::receive_commit, this);
// m_variables["connection_leech"] = rpc::call_command_void("protocol.connection.leech"); // m_variables["connection_leech"] = rpc::call_command_void("protocol.connection.leech");
// m_variables["connection_seed"] = rpc::call_command_void("protocol.connection.seed"); // m_variables["connection_seed"] = rpc::call_command_void("protocol.connection.seed");
+1 -1
View File
@@ -172,7 +172,7 @@ View::initialize(const std::string& name) {
m_focus = 0; m_focus = 0;
set_last_changed(rak::timer()); set_last_changed(rak::timer());
m_delayChanged.set_slot(std::tr1::bind(&signal_type::operator(), &m_signalChanged)); m_delayChanged.slot() = std::tr1::bind(&signal_type::operator(), &m_signalChanged);
} }
void void
+1 -1
View File
@@ -50,7 +50,7 @@ namespace display {
Manager::Manager() : Manager::Manager() :
m_forceRedraw(false) { m_forceRedraw(false) {
m_taskUpdate.set_slot(std::tr1::bind(&Manager::receive_update, this)); m_taskUpdate.slot() = std::tr1::bind(&Manager::receive_update, this);
} }
Manager::~Manager() { Manager::~Manager() {
+1 -1
View File
@@ -59,7 +59,7 @@ Window::Window(Canvas* canvas, int flags, extent_type minWidth, extent_type minH
m_maxWidth(maxWidth), m_maxWidth(maxWidth),
m_maxHeight(maxHeight) { m_maxHeight(maxHeight) {
m_taskUpdate.set_slot(std::tr1::bind(&Window::redraw, this)); m_taskUpdate.slot() = std::tr1::bind(&Window::redraw, this);
} }
Window::~Window() { Window::~Window() {
+1 -1
View File
@@ -48,7 +48,7 @@ WindowLog::WindowLog(core::Log* l) :
Window(new Canvas, 0, 0, 0, extent_full, extent_static), Window(new Canvas, 0, 0, 0, extent_full, extent_static),
m_log(l) { m_log(l) {
m_taskUpdate.set_slot(std::tr1::bind(&WindowLog::receive_update, this)), m_taskUpdate.slot() = std::tr1::bind(&WindowLog::receive_update, this);
// We're trying out scheduled tasks instead. // We're trying out scheduled tasks instead.
m_connUpdate = l->signal_update().connect(sigc::mem_fun(*this, &WindowLog::receive_update)); m_connUpdate = l->signal_update().connect(sigc::mem_fun(*this, &WindowLog::receive_update));
+1 -1
View File
@@ -71,7 +71,7 @@ CommandScheduler::insert(const std::string& key) {
delete *itr; delete *itr;
*itr = new CommandSchedulerItem(key); *itr = new CommandSchedulerItem(key);
(*itr)->set_slot(std::tr1::bind(&CommandScheduler::call_item, this, *itr)); (*itr)->slot() = std::tr1::bind(&CommandScheduler::call_item, this, *itr);
return itr; return itr;
} }
+7 -7
View File
@@ -51,22 +51,22 @@ public:
CommandSchedulerItem(const std::string& key) : m_key(key), m_interval(0) {} CommandSchedulerItem(const std::string& key) : m_key(key), m_interval(0) {}
~CommandSchedulerItem(); ~CommandSchedulerItem();
bool is_queued() const { return m_task.is_queued(); } bool is_queued() const { return m_task.is_queued(); }
void enable(rak::timer t); void enable(rak::timer t);
void disable(); void disable();
const std::string& key() const { return m_key; } const std::string& key() const { return m_key; }
torrent::Object& command() { return m_command; } torrent::Object& command() { return m_command; }
// 'interval()' should in the future return some more dynamic values. // 'interval()' should in the future return some more dynamic values.
uint32_t interval() const { return m_interval; } uint32_t interval() const { return m_interval; }
void set_interval(uint32_t v) { m_interval = v; } void set_interval(uint32_t v) { m_interval = v; }
rak::timer time_scheduled() const { return m_timeScheduled; } rak::timer time_scheduled() const { return m_timeScheduled; }
rak::timer next_time_scheduled() const; rak::timer next_time_scheduled() const;
void set_slot(const slot_void& s) { m_task.set_slot(s); } slot_void& slot() { return m_task.slot(); }
private: private:
CommandSchedulerItem(const CommandSchedulerItem&); CommandSchedulerItem(const CommandSchedulerItem&);
+1 -1
View File
@@ -108,7 +108,7 @@ public:
void throw_shutdown_exception() { throw torrent::shutdown_exception(); } void throw_shutdown_exception() { throw torrent::shutdown_exception(); }
ThreadBase::ThreadBase() { ThreadBase::ThreadBase() {
m_taskShutdown.set_slot(rak::ptr_fn(&throw_shutdown_exception)); m_taskShutdown.slot() = std::tr1::bind(&throw_shutdown_exception);
m_threadQueue = new thread_queue_hack; m_threadQueue = new thread_queue_hack;
} }
+1 -1
View File
@@ -52,7 +52,7 @@
#include "rpc/parse_commands.h" #include "rpc/parse_commands.h"
ThreadWorker::ThreadWorker() { ThreadWorker::ThreadWorker() {
m_taskTouchLog.set_slot(std::tr1::bind(&ThreadWorker::task_touch_log, this)); m_taskTouchLog.slot() = std::tr1::bind(&ThreadWorker::task_touch_log, this);
} }
ThreadWorker::~ThreadWorker() { ThreadWorker::~ThreadWorker() {