mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-15 14:42:30 +00:00
Do thread cleanup within the same thread context.
This commit is contained in:
@@ -2,26 +2,24 @@
|
||||
|
||||
#include "test_main_thread.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include <signal.h>
|
||||
|
||||
#include "test/helpers/mock_function.h"
|
||||
#include "torrent/exceptions.h"
|
||||
#include "torrent/poll.h"
|
||||
#include "torrent/net/resolver.h"
|
||||
#include "torrent/utils/log.h"
|
||||
#include "torrent/utils/scheduler.h"
|
||||
|
||||
std::unique_ptr<TestMainThread>
|
||||
TestMainThread::create() {
|
||||
// Needs to be called before Thread is created.
|
||||
mock_redirect_defaults();
|
||||
|
||||
auto thread = new TestMainThread();
|
||||
return std::unique_ptr<TestMainThread>(thread);
|
||||
return std::unique_ptr<TestMainThread>(new TestMainThread());
|
||||
}
|
||||
|
||||
TestMainThread::TestMainThread() {}
|
||||
|
||||
TestMainThread::~TestMainThread() {
|
||||
m_self = nullptr;
|
||||
std::unique_ptr<TestMainThread>
|
||||
TestMainThread::create_with_mock() {
|
||||
return std::unique_ptr<TestMainThread>(new TestMainThread());
|
||||
}
|
||||
|
||||
void
|
||||
@@ -34,6 +32,10 @@ TestMainThread::init_thread() {
|
||||
init_thread_local();
|
||||
}
|
||||
|
||||
void
|
||||
TestMainThread::cleanup_thread() {
|
||||
}
|
||||
|
||||
void
|
||||
TestMainThread::call_events() {
|
||||
process_callbacks();
|
||||
@@ -41,5 +43,36 @@ TestMainThread::call_events() {
|
||||
|
||||
std::chrono::microseconds
|
||||
TestMainThread::next_timeout() {
|
||||
return std::chrono::microseconds(10min);
|
||||
return 10min;
|
||||
}
|
||||
|
||||
void
|
||||
TestFixtureWithMainThread::setUp() {
|
||||
test_fixture::setUp();
|
||||
|
||||
m_main_thread = TestMainThread::create();
|
||||
m_main_thread->init_thread();
|
||||
}
|
||||
|
||||
void
|
||||
TestFixtureWithMainThread::tearDown() {
|
||||
m_main_thread.reset();
|
||||
|
||||
test_fixture::tearDown();
|
||||
}
|
||||
|
||||
void
|
||||
TestFixtureWithMockAndMainThread::setUp() {
|
||||
test_fixture::setUp();
|
||||
|
||||
m_main_thread = TestMainThread::create_with_mock();
|
||||
m_main_thread->init_thread();
|
||||
}
|
||||
|
||||
void
|
||||
TestFixtureWithMockAndMainThread::tearDown() {
|
||||
m_main_thread.reset();
|
||||
|
||||
test_fixture::tearDown();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user