Crawls through a directory with multiple worker threads, calling a calback function on each directory entry found.
More...
#include <45d/MTDirCrawler.hpp>
|
void | seed (const ffd_internal_fs::path &base_path) |
|
void | worker (std::function< bool(const ffd_internal_fs::directory_entry &)> callback) |
|
|
bool | done_ |
|
std::deque< ffd_internal_fs::directory_entry > | queue_ |
|
std::vector< std::thread > | workers_ |
|
std::atomic< int > | threads_running_ |
|
std::mutex | mutex_ |
|
std::condition_variable | cv_ |
|
Crawls through a directory with multiple worker threads, calling a calback function on each directory entry found.
◆ MTDirCrawler()
ffd::MTDirCrawler::MTDirCrawler |
( |
| ) |
|
|
inline |
◆ ~MTDirCrawler()
ffd::MTDirCrawler::~MTDirCrawler |
( |
| ) |
|
|
default |
◆ crawl()
void ffd::MTDirCrawler::crawl |
( |
ffd_internal_fs::path |
base_path, |
|
|
std::function< bool(const ffd_internal_fs::directory_entry &)> |
callback, |
|
|
int |
threads |
|
) |
| |
|
inline |
Kicks off thread workers and waits for them to finish.
The callback parameter needs to be a function that receives a directory_entry and returns a boolean. Return true from this function if the crawler should recurse into this directory entry given that it is a directory itself. To pass more parameters to the callback function, use std::bind().
Example:
- Parameters
-
base_path | Path to start the traversal from |
callback | Function to call on each directory entry, should return true if the directory entry should be recursed into |
threads | Number of worker threads to spawn |
◆ crawl_async()
void ffd::MTDirCrawler::crawl_async |
( |
ffd_internal_fs::path |
base_path, |
|
|
std::function< bool(const ffd_internal_fs::directory_entry &)> |
callback, |
|
|
int |
threads |
|
) |
| |
|
inline |
Kicks off thread workers. MTDirCrawler::wait() must be called at some point to join threads.
- Parameters
-
base_path | Path to start the traversal from |
callback | Function to call on each directory entry, should return true if the directory entry should be recursed into |
threads | Number of worker threads to spawn |
◆ wait()
void ffd::MTDirCrawler::wait |
( |
void |
| ) |
|
|
inline |
The documentation for this class was generated from the following file: