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

Method run

lib_acl_cpp/samples/db/mysql_pool/main.cpp:245–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243
244protected:
245 void* run()
246 {
247 int n = 0;
248
249 for (int i = 0; i < max_; i++)
250 {
251 acl::db_handle* db = pool_.peek_open();
252 if (db == NULL)
253 {
254 printf("peek db connection error\r\n");
255 break;
256 }
257
258 bool ret = tbl_insert(*db, i);
259 if (ret)
260 {
261 printf(">>insert ok: i=%d, affected: %d\r",
262 i, db->affect_count());
263 n++;
264 }
265 else
266 printf(">>insert error: i = %d\r\n", i);
267
268 pool_.put(db);
269 }
270 printf("\r\n");
271 printf(">>insert total: %d\r\n", n);
272
273 n = 0;
274 // ������ѯ����
275 for (int i = 0; i < max_; i++)
276 {
277 acl::db_handle* db = pool_.peek_open();
278 if (db == NULL)
279 {
280 printf("peek db connection error\r\n");
281 break;
282 }
283
284 int ret = tbl_select(*db, i);
285 if (ret >= 0)
286 {
287 n += ret;
288 printf(">>select ok: i=%d, ret=%d\r", i, ret);
289 }
290 else
291 printf(">>select error: i = %d\r\n", i);
292
293 pool_.put(db);
294 }
295 printf("\r\n");
296 printf(">>select total: %d\r\n", n);
297
298 // ����ɾ������
299 for (int i = 0; i < max_; i++)
300 {
301 acl::db_handle* db = pool_.peek_open();
302 if (db == NULL)

Callers

nothing calls this directly

Calls 6

peek_openMethod · 0.80
tbl_insertFunction · 0.70
tbl_selectFunction · 0.70
tbl_deleteFunction · 0.70
affect_countMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected