Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2bebdfa

Browse files
committed
Re-indent with Xcode.
Prepare for further changes.
1 parente144007 commit2bebdfa

File tree

1 file changed

+70
-70
lines changed

1 file changed

+70
-70
lines changed

‎include/network/utils/thread_pool.ipp‎

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -11,111 +11,111 @@
1111

1212
namespacenetwork {namespaceutils {
1313

14-
structthread_pool_pimpl {
14+
structthread_pool_pimpl {
1515
thread_pool_pimpl(
16-
std::size_t threads =1,
17-
io_service_ptr io_service = io_service_ptr(),
18-
worker_threads_ptr worker_threads = worker_threads_ptr()
19-
)
16+
std::size_t threads =1,
17+
io_service_ptr io_service = io_service_ptr(),
18+
worker_threads_ptr worker_threads = worker_threads_ptr()
19+
)
2020
: threads_(threads)
2121
, io_service_(io_service)
2222
, worker_threads_(worker_threads)
2323
, sentinel_()
2424
{
25-
bool commit =false;
26-
BOOST_SCOPE_EXIT((&commit)(&io_service_)(&worker_threads_)(&sentinel_)) {
27-
if (!commit) {
28-
sentinel_.reset();
29-
io_service_.reset();
30-
if (worker_threads_.get()) {
31-
worker_threads_->interrupt_all();
32-
worker_threads_->join_all();
33-
}
34-
worker_threads_.reset();
35-
}
36-
} BOOST_SCOPE_EXIT_END
37-
38-
if (!io_service_.get()) {
39-
io_service_.reset(new boost::asio::io_service);
25+
bool commit =false;
26+
BOOST_SCOPE_EXIT((&commit)(&io_service_)(&worker_threads_)(&sentinel_)) {
27+
if (!commit) {
28+
sentinel_.reset();
29+
io_service_.reset();
30+
if (worker_threads_.get()) {
31+
worker_threads_->interrupt_all();
32+
worker_threads_->join_all();
33+
}
34+
worker_threads_.reset();
4035
}
36+
} BOOST_SCOPE_EXIT_END
4137

42-
if (!worker_threads_.get()) {
43-
worker_threads_.reset(new boost::thread_group);
44-
}
38+
if (!io_service_.get()) {
39+
io_service_.reset(new boost::asio::io_service);
40+
}
4541

46-
if (!sentinel_.get()) {
47-
sentinel_.reset(newboost::asio::io_service::work(*io_service_));
48-
}
42+
if (!worker_threads_.get()) {
43+
worker_threads_.reset(new boost::thread_group);
44+
}
4945

50-
for (std::size_t counter =0; counter < threads_; ++counter)
51-
worker_threads_->create_thread(
52-
boost::bind(
53-
&boost::asio::io_service::run,
54-
io_service_
55-
)
56-
);
46+
if (!sentinel_.get()) {
47+
sentinel_.reset(newboost::asio::io_service::work(*io_service_));
48+
}
5749

58-
commit =true;
50+
for (std::size_t counter =0; counter < threads_; ++counter)
51+
worker_threads_->create_thread(
52+
boost::bind(
53+
&boost::asio::io_service::run,
54+
io_service_
55+
)
56+
);
57+
58+
commit =true;
5959
}
6060

6161
std::size_tconstthread_count()const {
62-
return threads_;
62+
return threads_;
6363
}
6464

6565
voidpost(boost::function<void()> f) {
66-
io_service_->post(f);
66+
io_service_->post(f);
6767
}
6868

6969
~thread_pool_pimpl() {
70-
sentinel_.reset();
71-
try {
72-
worker_threads_->join_all();
73-
}catch (...) {
74-
BOOST_ASSERT(false &&"A handler was not supposed to throw, but one did.");
75-
std::abort();
76-
}
70+
sentinel_.reset();
71+
try {
72+
worker_threads_->join_all();
73+
}catch (...) {
74+
BOOST_ASSERT(false &&"A handler was not supposed to throw, but one did.");
75+
std::abort();
76+
}
7777
}
7878

7979
voidswap(thread_pool_pimpl & other) {
80-
std::swap(other.threads_, threads_);
81-
std::swap(other.io_service_, io_service_);
82-
std::swap(other.worker_threads_, worker_threads_);
83-
std::swap(other.sentinel_, sentinel_);
80+
std::swap(other.threads_, threads_);
81+
std::swap(other.io_service_, io_service_);
82+
std::swap(other.worker_threads_, worker_threads_);
83+
std::swap(other.sentinel_, sentinel_);
8484
}
85-
protected:
85+
protected:
8686
std::size_t threads_;
8787
io_service_ptr io_service_;
8888
worker_threads_ptr worker_threads_;
8989
sentinel_ptr sentinel_;
9090

91-
private:
91+
private:
9292
thread_pool_pimpl(thread_pool_pimplconst &);// no copies please
9393
thread_pool_pimpl &operator=(thread_pool_pimpl);// no assignment please
94-
};
94+
};
9595

96-
thread_pool::thread_pool(std::size_t threads,
97-
io_service_ptr io_service,
98-
worker_threads_ptr worker_threads)
99-
: pimpl(new (std::nothrow) thread_pool_pimpl(threads, io_service, worker_threads))
100-
{}
96+
thread_pool::thread_pool(std::size_t threads,
97+
io_service_ptr io_service,
98+
worker_threads_ptr worker_threads)
99+
: pimpl(new (std::nothrow) thread_pool_pimpl(threads, io_service, worker_threads))
100+
{}
101101

102-
std::size_tconstthread_pool::thread_count()const {
103-
return pimpl->thread_count();
104-
}
102+
std::size_tconstthread_pool::thread_count()const {
103+
return pimpl->thread_count();
104+
}
105105

106-
voidthread_pool::post(boost::function<void()> f) {
107-
pimpl->post(f);
108-
}
109-
110-
voidthread_pool::swap(thread_pool & other) {
111-
std::swap(other.pimpl,this->pimpl);
112-
}
113-
114-
thread_pool::~thread_pool() {
115-
delete pimpl;
116-
}
106+
voidthread_pool::post(boost::function<void()> f) {
107+
pimpl->post(f);
108+
}
117109

110+
voidthread_pool::swap(thread_pool & other) {
111+
std::swap(other.pimpl,this->pimpl);
112+
}
113+
114+
thread_pool::~thread_pool() {
115+
delete pimpl;
116+
}
117+
118118
}// namespace utils
119119
}// namespace network
120-
120+
121121
#endif/* NETWORK_UTILS_THREAD_POOL_IPP_20111021*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp