- print_size: print file size
- print_permitions: print file permitions
- print_modified_date: print modified date
using f1 = print_size;
using f2 = print_permitions;
using f3 = print_modified_date;
bool print_info(const path& p) {
bool is_ok = true;
is_ok &= f1(p);
is_ok &= f2(p);
is_ok &= f3(p);
return is_ok;
}
using f = print_info;
$ ./explorer p1 p2 p3 p4 p5 p6
int main(int argc, char* argv[]) {
scheduler_t scheduler;
std::map<path, std::future<bool>> results;
for (int i = 1; i < argc; ++i) {
path p = argv[i];
auto task = std::package_task<bool()>{ std::bind(f, p) };
auto result = task.get_future();
sheduler.add(task);
results.emplace(p, std::move(result));
}
scheduler.run(); // run in a new thred
for(auto & p : results) {
auto& result = results[p];
auto is_ok = result.get();
if (! is_ok) {
std::cerr << "<your error message>:" << p << std::endl;
}
}
}
task1 task2 task3 task4 task5 task6
+-------+ +-------+ +-------+ +-------+ +-------+ +-------+
| f{p1} | | f{p2} | | f{p3} | | f{p4} | | f{p5} | | f{p6} |
+-------+ +-------+ +-------+ +-------+ +-------+ +-------+
^
| +-----------+
+----------| scheduler |
+-----------+
main run
----------------------------------------------------->
\
\
\--------------------------------------------->
\ \
\ task1 \ task5
\------------>{r1} \------------>{r5}
\ \
\ task2 \ task6
\------------>{r2} \------------>{r6}
\
\ task3
\------------>{r3}
\
\ task4
\------------>{r4}
std::thread::hardware_concurrency() == 4;