// #include "../lib/loop.hpp" // #include "../lib/asynco.hpp" // #include "../example/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(8); #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); // 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(); // }, 2000); // cout << "zadataka: " << on_async.count_tasks() << " niti: " << on_async.count_threads() << endl; // 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 " < ev2int; // event evintString; // ev2int.on("sum", [](int a, int b) { // cout << "Sum " << a+b << endl; // }); // evintString.on("substract", [](int a, string b) { // cout << "Substract " << a-stoi(b) << endl; // }); // sleep(5); // ev2int.emit("sum", 5, 8); // sleep(2); // evintString.emit("substract", 3, to_string(2)); sleep(1000); return 0; }