MCPcopy Create free account
hub / github.com/acl-dev/acl / rpc_run

Method rpc_run

app/master/tools/master_dispatch/server/status/HttpClientRpc.cpp:21–56  ·  view source on GitHub ↗

子线程中运行

Source from the content-addressed store, hash-verified

19
20// 子线程中运行
21void HttpClientRpc::rpc_run()
22{
23 std::vector<acl::string>& servers = server_addrs_.split2(";, \t");
24 size_t size = servers.size();
25 if (size == 0)
26 {
27 logger_error("invalid server_addrs: %s", server_addrs_.c_str());
28 return;
29 }
30 else if (size == 1)
31 {
32 // 当只有一个管理服务器时,则不必启动线程,直接在本线程中处理
33 HttpClient job(servers[0], buf_);
34 job.run();
35 return;
36 }
37
38 // 当需要向多个管理服务,则为了保证实时性,则将发送任务放在线程池
39 // 中去处理
40 acl::thread_pool threads;
41
42 // 启动线程池过程
43 threads.start();
44
45 // 将发送任务交给线程池处理
46 std::vector<acl::string>::const_iterator cit = servers.begin();
47 for (; cit != servers.end(); ++cit)
48 {
49 HttpClient* job = new HttpClient((*cit).c_str(), buf_);
50 job->set_auto_free(true);
51 threads.execute(job);
52 }
53
54 // 等待所有线程发送完毕
55 threads.wait();
56}
57
58
59/////////////////////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 9

beginMethod · 0.80
set_auto_freeMethod · 0.80
sizeMethod · 0.45
c_strMethod · 0.45
runMethod · 0.45
startMethod · 0.45
endMethod · 0.45
executeMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected