mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 14:12:31 +00:00
Cleaned up thread code.
This commit is contained in:
+3
-3
@@ -169,12 +169,12 @@ SCgi::receive_call(SCgiTask* task, const char* buffer, uint32_t length) {
|
||||
slot_write slotWrite;
|
||||
slotWrite.set(rak::mem_fn(task, &SCgiTask::receive_write));
|
||||
|
||||
ThreadBase::acquire_global_lock();
|
||||
ThreadBase::interrupt_main_polling();
|
||||
torrent::thread_base::acquire_global_lock();
|
||||
torrent::main_thread()->interrupt();
|
||||
|
||||
bool result = xmlrpc.process(buffer, length, slotWrite);
|
||||
|
||||
ThreadBase::release_global_lock();
|
||||
torrent::thread_base::release_global_lock();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -162,18 +162,3 @@ ThreadBase::queue_item(thread_base_func newFunc) {
|
||||
if (m_state == STATE_ACTIVE)
|
||||
interrupt();
|
||||
}
|
||||
|
||||
void
|
||||
ThreadBase::interrupt_main_polling() {
|
||||
int sleep_length = 0;
|
||||
|
||||
while (ThreadBase::is_main_polling()) {
|
||||
torrent::main_thread()->interrupt();
|
||||
|
||||
if (!ThreadBase::is_main_polling())
|
||||
return;
|
||||
|
||||
usleep(sleep_length);
|
||||
sleep_length = std::min(sleep_length + 50, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,14 +66,6 @@ public:
|
||||
|
||||
void queue_item(thread_base_func newFunc);
|
||||
|
||||
// Only call this when global lock has been acquired, as it checks
|
||||
// ThreadBase::is_main_polling() which is only guaranteed to remain
|
||||
// 'false' if global lock keeps main thread from entering polling
|
||||
// again.
|
||||
//
|
||||
// Move to libtorrent some day.
|
||||
static void interrupt_main_polling();
|
||||
|
||||
protected:
|
||||
int64_t next_timeout_usec();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user