| 38 | } |
| 39 | |
| 40 | TEST_F(KVDBTest, AbstractKVDB_Thread_Test) { |
| 41 | if (my_argc != 3) { |
| 42 | std::cerr << "illegal input! should be db_thread ${num_of_thread} " |
| 43 | "${num_of_ops_each_thread}" |
| 44 | << std::endl; |
| 45 | return; |
| 46 | } |
| 47 | int num_of_thread = atoi(my_argv[1]); |
| 48 | int nums_of_ops_each_thread = atoi(my_argv[2]); |
| 49 | std::vector<AbsKVDBPtr> kvdbptrs; |
| 50 | for (int i = 0; i < num_of_thread; i++) { |
| 51 | kvdbptrs.push_back(std::make_shared<RocksKVDB>()); |
| 52 | kvdbptrs[i]->CreateDB(); |
| 53 | } |
| 54 | std::vector<std::thread> tarr; |
| 55 | for (int i = 0; i < num_of_thread; i++) { |
| 56 | tarr.push_back( |
| 57 | std::thread(db_thread_test, kvdbptrs[i], nums_of_ops_each_thread)); |
| 58 | } |
| 59 | for (int i = 0; i < num_of_thread; i++) { |
| 60 | tarr[i].join(); |
| 61 | } |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | int main(int argc, char** argv) { |
| 66 | my_argc = argc; |