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

Function main

lib_acl_cpp/samples/dbpool/main.cpp:5–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3using namespace acl;
4
5int main(void)
6{
7 db_pool *dp = new mysql_pool("127.0.0.1:3306", "test_db", "zsxxsz",
8 "111111");
9
10 std::list<db_handle*> dbs;
11
12 // 设置空闲连接的生存周期
13 dp->set_idle(1);
14 for (int i = 0; i < 10; i++)
15 {
16 db_handle* dh = (db_handle*) dp->peek();
17 dbs.push_back(dh);
18 }
19
20 std::list<db_handle*>::iterator it = dbs.begin();
21 for (; it != dbs.end(); ++it)
22 {
23 dp->put(*it);
24 //sleep(1);
25 }
26
27 dbs.clear();
28
29 printf("dbpool count: %d\r\n", dp->get_dbcount());
30 sleep(2);
31 db_handle* dh = dp->peek();
32 dp->put(dh);
33 printf("dbpool count: %d\r\n", dp->get_dbcount());
34 delete dp;
35
36 return 0;
37}

Callers

nothing calls this directly

Calls 7

beginMethod · 0.80
sleepFunction · 0.50
peekMethod · 0.45
push_backMethod · 0.45
endMethod · 0.45
putMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…