|
|
|
@ -69,9 +69,9 @@ int main () { |
|
|
|
|
|
|
|
|
|
// --------------- TIME ASYNCHRONOUS FUNCTIONS --------------
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Init periodic and delayed; clear periodic and delayed |
|
|
|
|
*/ |
|
|
|
|
// /**
|
|
|
|
|
// * Init periodic and delayed; clear periodic and delayed
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
|
|
// periodic inter1 ([&]() {
|
|
|
|
|
// cout << "periodic prvi " << rtime_ms() - start << endl;
|
|
|
|
@ -129,30 +129,11 @@ int main () { |
|
|
|
|
// cout << "nije isteko " << endl;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// auto d = Delayed( [](){
|
|
|
|
|
// cout << "Delayed" << endl;
|
|
|
|
|
// }, 2000);
|
|
|
|
|
|
|
|
|
|
// auto p = Periodic( [](){
|
|
|
|
|
// cout << "Periodic" << endl;
|
|
|
|
|
// }, 700);
|
|
|
|
|
// // // ------------------------ MAKE FUNCTIONS ASYNCHRONOUS -------------------------
|
|
|
|
|
|
|
|
|
|
// Periodic( [&] (){
|
|
|
|
|
// cout << "Delayed expire " << d->expired() << endl;
|
|
|
|
|
// cout << "Periodic ticks " << p->ticks() << endl;
|
|
|
|
|
// cout << "Delayed stoped " << d->stoped() << endl;
|
|
|
|
|
// cout << "Periodic stoped " << p->stoped() << endl;
|
|
|
|
|
// }, 1000);
|
|
|
|
|
|
|
|
|
|
// Delayed( [&](){
|
|
|
|
|
// p->stop();
|
|
|
|
|
// }, 10000);
|
|
|
|
|
|
|
|
|
|
// // // // ------------------------ MAKE FUNCTIONS ASYNCHRONOUS -------------------------
|
|
|
|
|
|
|
|
|
|
// // /**
|
|
|
|
|
// // * Run an function asyncronic
|
|
|
|
|
// // */
|
|
|
|
|
// /**
|
|
|
|
|
// * Run an function asyncronic
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
|
|
// async_ ( []() {
|
|
|
|
|
// sleep_for(2s); // only for simulate log duration function
|
|
|
|
@ -174,13 +155,13 @@ int main () { |
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // async(launch::async, [] () {
|
|
|
|
|
// // cout << "Another thread in async style!" << endl;
|
|
|
|
|
// // });
|
|
|
|
|
// async(launch::async, [] () {
|
|
|
|
|
// cout << "Another thread in async style!" << endl;
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// // /**
|
|
|
|
|
// // * Call class method
|
|
|
|
|
// // */
|
|
|
|
|
// /**
|
|
|
|
|
// * Call class method
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
|
|
// clm classes;
|
|
|
|
|
// async_ ( [&classes] () {
|
|
|
|
@ -189,17 +170,17 @@ int main () { |
|
|
|
|
|
|
|
|
|
// sleep(5);
|
|
|
|
|
|
|
|
|
|
// // /**
|
|
|
|
|
// // * await_ after runned as async
|
|
|
|
|
// // */
|
|
|
|
|
// /**
|
|
|
|
|
// * await_ after runned as async
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
|
|
// auto aa = async_ ( []() {
|
|
|
|
|
// auto a = async_ ( []() {
|
|
|
|
|
// sleep_for(2s); // only for simulate log duration function
|
|
|
|
|
// cout << "async_ 2" << endl;
|
|
|
|
|
// return 5;
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// cout << await_(aa) << endl;
|
|
|
|
|
// cout << await_(a) << endl;
|
|
|
|
|
// cout << "print after async_ 2" << endl;
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
@ -290,19 +271,17 @@ int main () { |
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// auto await_all2 = [&] () {
|
|
|
|
|
// auto await_all = [&] () {
|
|
|
|
|
// for (int i=0; i<fut_vec.size(); i++) {
|
|
|
|
|
// await_ (fut_vec[i]);
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// await_all2();
|
|
|
|
|
// --------------- EVENTS -------------------
|
|
|
|
|
|
|
|
|
|
// // --------------- EVENTS -------------------
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
// * initialization of typed events
|
|
|
|
|
// */
|
|
|
|
|
/**
|
|
|
|
|
* initialization of typed events |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
// trigger<int, int> ev2int;
|
|
|
|
|
// trigger<int, string> evintString;
|
|
|
|
|