From 052e8df93d7ea8918894dc1f79fb25edd226b36c Mon Sep 17 00:00:00 2001 From: marcelb Date: Wed, 27 Mar 2024 17:40:39 +0100 Subject: [PATCH] Fix filesystem typed mistake --- lib/filesystem.hpp | 8 ++++---- test/test.cpp | 44 ++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/filesystem.hpp b/lib/filesystem.hpp index 60eabe5..bd9faeb 100644 --- a/lib/filesystem.hpp +++ b/lib/filesystem.hpp @@ -20,7 +20,7 @@ namespace fs { */ template void read(string path, Callback&& callback) { - async( [&path, callback] () { + atask( [&path, callback] () { string content; try { string line; @@ -49,7 +49,7 @@ void read(string path, Callback&& callback) { * Asynchronous file reading */ future read(string path) { - return async( [&path] () { + return atask( [&path] () { string content; string line; ifstream file (path); @@ -73,7 +73,7 @@ future read(string path) { */ template void write(string path, string content, Callback&& callback) { - async( [&path, &content, callback] () { + atask( [&path, &content, callback] () { try { ofstream file (path); if (file.is_open()) { @@ -96,7 +96,7 @@ void write(string path, string content, Callback&& callback) { * Asynchronous file writing with callback after write complete */ future write(string path, string content) { - return async( [&path, &content] () { + return atask( [&path, &content] () { ofstream file (path); if (file.is_open()) { file << content; diff --git a/test/test.cpp b/test/test.cpp index ac47252..d698a30 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -3,7 +3,7 @@ #include "../lib/asynco.hpp" #include "../lib/event.hpp" #include "../lib/rotor.hpp" -// #include "../lib/filesystem.hpp" +#include "../lib/filesystem.hpp" #include #include @@ -11,7 +11,7 @@ using namespace std; using namespace marcelb::asynco; using namespace events; -// using namespace asynco; +using namespace asynco; using namespace this_thread; void sleep_to (int _time) { @@ -88,17 +88,17 @@ int main () { // cout << "interval 4: " << rtime_ms() - start << endl; // }, 400); - interval inter1 ([&]() { - cout << "interval prvi " << rtime_ms() - start << endl; - }, 1000); + // interval inter1 ([&]() { + // cout << "interval prvi " << rtime_ms() - start << endl; + // }, 1000); - interval inter2 ([&]() { - cout << "interval drugi " << rtime_ms() - start << endl; - }, 2000); + // interval inter2 ([&]() { + // cout << "interval drugi " << rtime_ms() - start << endl; + // }, 2000); - interval inter3 ([&]() { - cout << "interval treći " << rtime_ms() - start << endl; - }, 3000); + // interval inter3 ([&]() { + // cout << "interval treći " << rtime_ms() - start << endl; + // }, 3000); // interval inter4 ([&]() { // cout << "interval cetvrti " << rtime_ms() - start << endl; @@ -112,13 +112,13 @@ int main () { // cout << "interval sesti " << rtime_ms() - start << endl; // }, 3000); - timeout time1 ( [&] () { - cout << "Close interval 1 i 2 " << rtime_ms() - start << endl; - // inter1.clear(); - // cout << "inter1.stop " << inter1.stop << endl; - // inter2.clear(); - // cout << "inter2.stop " << inter2.stop << endl; - }, 5000); + // timeout time1 ( [&] () { + // cout << "Close interval 1 i 2 " << rtime_ms() - start << endl; + // // inter1.clear(); + // // cout << "inter1.stop " << inter1.stop << endl; + // // inter2.clear(); + // // cout << "inter2.stop " << inter2.stop << endl; + // }, 5000); // timeout time2 ([&] () { @@ -127,11 +127,11 @@ int main () { // time1.clear(); // }, 2000); - // // ------------------------ MAKE FUNCTIONS ASYNCHRONOUS ------------------------- + // // // ------------------------ MAKE FUNCTIONS ASYNCHRONOUS ------------------------- - /** - * Run an function asyncronic - */ + // /** + // * Run an function asyncronic + // */ // atask( []() { // sleep_for(2s); // only for simulate log duration function