src/​examples/​cpp03/​http/​server/​connection_manager.​cppsrc/​examples/​cpp11/​http/​server/​connection_manager.​cpp
1 /​/​1 /​/​
2 /​/​·​connection_manager.​cpp2 /​/​·​connection_manager.​cpp
3 /​/​·​~~~~~~~~~~~~~~~~~~~~~​~3 /​/​·​~~~~~~~~~~~~~~~~~~~~~​~
4 /​/​4 /​/​
5 /​/​·​Copyright·​(c)​·​2003-​2022·​Christopher·​M.​·​Kohlhoff·​(chris·​at·​kohlhoff·​dot·​com)​5 /​/​·​Copyright·​(c)​·​2003-​2022·​Christopher·​M.​·​Kohlhoff·​(chris·​at·​kohlhoff·​dot·​com)​
6 /​/​6 /​/​
7 /​/​·​Distributed·​under·​the·​Boost·​Software·​License,​·​Version·​1.​0.​·​(See·​accompanying7 /​/​·​Distributed·​under·​the·​Boost·​Software·​License,​·​Version·​1.​0.​·​(See·​accompanying
8 /​/​·​file·​LICENSE_1_0.​txt·​or·​copy·​at·​http:​/​/​www.​boost.​org/​LICENSE_1_0.​txt)​8 /​/​·​file·​LICENSE_1_0.​txt·​or·​copy·​at·​http:​/​/​www.​boost.​org/​LICENSE_1_0.​txt)​
9 /​/​9 /​/​
10 10
11 #include·​"connection_manager.​hpp"11 #include·​"connection_manager.​hpp"
12 #include·​<algorithm>
13 #include·​<boost/​bind/​bind.​hpp>
14 12
15 namespace·​http·​{13 namespace·​http·​{
16 namespace·​server·​{14 namespace·​server·​{
17 15
16 connection_manager:​:​connection_manager()​
17 {
18 }
19
18 void·​connection_manager:​:​start(connection_ptr·​c)​20 void·​connection_manager:​:​start(connection_ptr·​c)​
19 {21 {
20 ··​connections_.​insert(c)​;​22 ··​connections_.​insert(c)​;​
21 ··​c-​>start()​;​23 ··​c-​>start()​;​
22 }24 }
23 25
24 void·​connection_manager:​:​stop(connection_ptr·​c)​26 void·​connection_manager:​:​stop(connection_ptr·​c)​
25 {27 {
26 ··​connections_.​erase(c)​;​28 ··​connections_.​erase(c)​;​
27 ··​c-​>stop()​;​29 ··​c-​>stop()​;​
28 }30 }
29 31
30 void·​connection_manager:​:​stop_all()​32 void·​connection_manager:​:​stop_all()​
31 {33 {
32 ··std:​:​for_each(connections_​.​begin()​,​·​connections_.​end()​,​34 ··​for·(auto·c:​·​connections_)​
33 ······boost:​:​bind(&connection:​:​stop,​·boost:​:​placeholders:​:​_1)​)​;​35 ····​c-​>stop()​;​
34 ··​connections_.​clear()​;​36 ··​connections_.​clear()​;​
35 }37 }
36 38
37 }·​/​/​·​namespace·​server39 }·​/​/​·​namespace·​server
38 }·​/​/​·​namespace·​http40 }·​/​/​·​namespace·​http