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

Method run

lib_acl_cpp/samples/db/pgsql_pool/main.cpp:194–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192
193protected:
194 void* run()
195 {
196 int n = 0;
197
198 for (int i = 0; i < max_; i++)
199 {
200 acl::db_handle* db = pool_.peek_open();
201 if (db == NULL)
202 {
203 printf("peek db connection error\r\n");
204 break;
205 }
206
207 bool ret = tbl_insert(*db, i);
208 if (ret)
209 {
210 printf(">>insert ok: i=%d, affected: %d\r",
211 i, db->affect_count());
212 n++;
213 }
214 else
215 printf(">>insert error: i = %d\r\n", i);
216
217 pool_.put(db);
218 }
219 printf("\r\n");
220 printf(">>insert total: %d\r\n", n);
221 getchar();
222
223 n = 0;
224 // ������ѯ����
225 for (int i = 0; i < max_; i++)
226 {
227 acl::db_handle* db = pool_.peek_open();
228 if (db == NULL)
229 {
230 printf("peek db connection error\r\n");
231 break;
232 }
233
234 int ret = tbl_select(*db, i);
235 if (ret >= 0)
236 {
237 n += ret;
238 printf(">>select ok: i=%d, ret=%d\r", i, ret);
239 }
240 else
241 printf(">>select error: i = %d\r\n", i);
242
243 pool_.put(db);
244 }
245 printf("\r\n");
246 printf(">>select total: %d\r\n", n);
247
248 // ����ɾ������
249 for (int i = 0; i < max_; i++)
250 {
251 acl::db_handle* db = pool_.peek_open();

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