Skip to content
API Documentation
BastionGuard™
scan_worker.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "models.hpp"
4#include <atomic>
5#include <functional>
6#include <string>
7#include <thread>
8
9class ScanWorker {
10public:
11 using CompletionCallback = std::function<void(const ScanReport&)>;
12 using ProgressCallback = std::function<void(const ScanProgress&)>;
13
16
17 void start(const std::string& path,
19 ProgressCallback progress_cb = {});
20
21 bool running() const;
22 void join();
23
24 // NEW
25 void request_cancel();
26 bool cancel_requested() const;
27
28private:
29 std::atomic<bool> running_{false};
30 std::atomic<bool> cancel_requested_{false};
31
32 std::thread thread_;
33};
static std::atomic< bool > running
std::atomic< bool > cancel_requested_
void request_cancel()
std::function< void(const ScanReport &)> CompletionCallback
bool cancel_requested() const
void start(const std::string &path, CompletionCallback cb, ProgressCallback progress_cb={})
std::atomic< bool > running_
std::thread thread_
std::function< void(const ScanProgress &)> ProgressCallback