|
|
|
@ -14,8 +14,9 @@ using namespace marcelb::asynco; |
|
|
|
|
int main() { |
|
|
|
|
auto inis = rtime_ms(); |
|
|
|
|
try { |
|
|
|
|
const int n = 30; |
|
|
|
|
// MySQL mydb("tcp://192.168.2.10:3306", "dinio", "H€r5elfInd1aH@nds", "dinio", 5, time_loop_type::internal);
|
|
|
|
|
MySQL mydb("tcp://bitelex.ddns.net:3306", "dinio", "H€r5elfInd1aH@nds", "dinio", 12, time_loop_type::external); |
|
|
|
|
MySQL mydb("tcp://bitelex.ddns.net:3306", "dinio", "H€r5elfInd1aH@nds", "dinio", n, time_loop_type::external); |
|
|
|
|
// MySQL mydb("tcp://bitelex.ddns.net:3306", "dinio", "H€r5elfInd1aH@nds", "dinio", 5);
|
|
|
|
|
|
|
|
|
|
cout << "init: " << rtime_ms() - inis << endl; |
|
|
|
@ -25,14 +26,44 @@ int main() { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
periodic mysql_tloop ( [&mydb] () { |
|
|
|
|
try { |
|
|
|
|
auto start = rtime_ms(); |
|
|
|
|
mydb.tloop(); |
|
|
|
|
cout << "loop--------------------------- nema error, trajalo: " << rtime_ms() - start << endl; |
|
|
|
|
} catch (...) { |
|
|
|
|
cout << "Bude neki error u loopu" << endl; |
|
|
|
|
auto l_start = rtime_ms(); |
|
|
|
|
vector<future<void>> to_wait; |
|
|
|
|
for (int i=0, old_i=0; i<n; old_i=i) { |
|
|
|
|
i += 5; |
|
|
|
|
to_wait.push_back( nonsync ([&, i, old_i](){ |
|
|
|
|
try { |
|
|
|
|
auto start = rtime_ms(); |
|
|
|
|
mydb.tloop(old_i, i); |
|
|
|
|
cout << "old " << old_i << " i " << i << endl; |
|
|
|
|
cout << "loop--------------------------- nema error, trajalo: " << rtime_ms() - start << endl; |
|
|
|
|
} catch (...) { |
|
|
|
|
cout << "Bude neki error u loopu" << endl; |
|
|
|
|
} |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
// nonsync ([&](){
|
|
|
|
|
// try {
|
|
|
|
|
// auto start = rtime_ms();
|
|
|
|
|
// mydb.tloop(4, 8);
|
|
|
|
|
// cout << "loop--------------------------- nema error, trajalo: " << rtime_ms() - start << endl;
|
|
|
|
|
// } catch (...) {
|
|
|
|
|
// cout << "Bude neki error u loopu" << endl;
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// nonsync ([&](){
|
|
|
|
|
// try {
|
|
|
|
|
// auto start = rtime_ms();
|
|
|
|
|
// mydb.tloop(8, 12);
|
|
|
|
|
// cout << "loop--------------------------- nema error, trajalo: " << rtime_ms() - start << endl;
|
|
|
|
|
// } catch (...) {
|
|
|
|
|
// cout << "Bude neki error u loopu" << endl;
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
for (auto& tw : to_wait) { |
|
|
|
|
wait (tw); |
|
|
|
|
} |
|
|
|
|
}, 2000); |
|
|
|
|
cout << "all loop !!!!!!!!!!!!!!1, trajalo: " << rtime_ms() - l_start << endl; |
|
|
|
|
}, 5000); |
|
|
|
|
|
|
|
|
|
while (true) { |
|
|
|
|
sleep(60); |
|
|
|
|