This commit is contained in:
qicosmos
2019-03-02 12:06:35 +08:00
parent 65c5c3b7e7
commit 0e2aaa995f
4 changed files with 10 additions and 9 deletions
-8
View File
@@ -5,11 +5,6 @@
#include <vector>
#include <memory>
#include <boost/noncopyable.hpp>
//#include <boost/shared_ptr.hpp>
//#include <stdexcept>
//#include <boost/thread/thread.hpp>
//#include <boost/bind.hpp>
//#include <boost/shared_ptr.hpp>
namespace rest_rpc {
namespace rpc_service {
@@ -26,8 +21,6 @@ class io_service_pool : private boost::noncopyable {
}
}
~io_service_pool() { stop(); }
void run() {
std::vector<std::shared_ptr<std::thread>> threads;
for (std::size_t i = 0; i < io_services_.size(); ++i) {
@@ -41,7 +34,6 @@ class io_service_pool : private boost::noncopyable {
void stop() {
for (std::size_t i = 0; i < io_services_.size(); ++i) {
io_services_[i]->stop();
io_services_[i]->reset();
}
}
+3
View File
@@ -75,6 +75,9 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>msgpack/include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>msgpack/include;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
+4 -1
View File
@@ -26,6 +26,8 @@ class rpc_server : private boost::noncopyable {
}
~rpc_server() {
stop_check_ = true;
check_thread_->join();
io_service_pool_.stop();
thd_->join();
}
@@ -68,7 +70,7 @@ class rpc_server : private boost::noncopyable {
}
void clean() {
while (true) {
while (!stop_check_) {
std::this_thread::sleep_for(std::chrono::seconds(check_seconds_));
std::unique_lock<std::mutex> lock(mtx_);
@@ -98,6 +100,7 @@ class rpc_server : private boost::noncopyable {
std::mutex mtx_;
std::shared_ptr<std::thread> check_thread_;
size_t check_seconds_;
bool stop_check_ = false;
};
} // namespace rpc_service
} // namespace rest_rpc
+3
View File
@@ -72,6 +72,9 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>..\msgpack\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>..\msgpack\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>