#include "../lib/loop.hpp" #include "../lib/asynco.hpp" // #include "../lib/event.hpp" #include #include using namespace std; using namespace marcelb; using namespace this_thread; #ifndef ON_ASYNC #define ON_ASYNC AsyncLoop on_async; #endif int main () { auto start = chrono::high_resolution_clock::now(); interval inter1 ([&]() { cout << "interval prvi " << chrono::duration_cast(chrono::high_resolution_clock::now() - start).count() << endl; }, 1000); cout << "Blokira stoka" << endl; interval inter2 ([&]() { cout << "interval drugi " << chrono::duration_cast(chrono::high_resolution_clock::now() - start).count() << endl; }, 2000); interval inter3 ([&]() { cout << "interval treći " << chrono::duration_cast(chrono::high_resolution_clock::now() - start).count() << endl; }, 3000); timeout time1 ( [&] () { cout << "Close interval 1 i 2 " << chrono::duration_cast(chrono::high_resolution_clock::now() - start).count() << endl; inter1.clear(); inter2.clear(); }, 10000); timeout time2 ([&] () { cout << "Close interval 3 " << chrono::duration_cast(chrono::high_resolution_clock::now() - start).count() << endl; inter3.clear(); }, 20000); // for (int i = 0; i < 8; ++i) { // pool.put_task( [&] (int id) { // this_thread::sleep_for(chrono::seconds(1)); // cout << a*i << endl; // }, i); // } // auto res1 = pool.put_task( [] () { // cout << "Jebiga " <