namespace Csr {
namespace Client {
-AsyncLogic::AsyncLogic(HandleExt *handle, void *userdata,
- const std::function<bool()> &isStopped) :
+AsyncLogic::AsyncLogic(HandleExt *handle, void *userdata) :
m_handle(handle),
m_ctx(new CsContext),
m_cb(handle->m_cb),
m_userdata(userdata),
- m_isStopped(isStopped),
m_dispatcher(new Dispatcher(SockId::CS))
{
// disable ask user option for async request for now
void AsyncLogic::scanFiles(const StrSet &fileSet)
{
for (const auto &file : fileSet) {
- if (this->m_isStopped())
+ if (this->m_handle->isStopped())
ThrowExc(-999, "Async op cancelled!");
auto ret = this->m_dispatcher->methodCall<std::pair<int, CsDetected *>>(
class AsyncLogic {
public:
- AsyncLogic(HandleExt *handle, void *userdata,
- const std::function<bool()> &isStopped);
+ AsyncLogic(HandleExt *handle, void *userdata);
virtual ~AsyncLogic();
void scanFiles(const StrSet &files);
template<typename T>
void copyKvp(CsContext::Key);
- Handle *m_handle; // for registering results for auto-release
+ HandleExt *m_handle; // for registering results for auto-release
ContextPtr m_ctx;
std::vector<ResultPtr> m_results;
Callback m_cb;
void *m_userdata;
- std::function<bool()> m_isStopped;
std::unique_ptr<Dispatcher> m_dispatcher;
};
{
T value;
- m_handle->getContext()->get(static_cast<int>(key), value);
- m_ctx->set(static_cast<int>(key), value);
+ this->m_handle->getContext()->get(static_cast<int>(key), value);
+ this->m_ctx->set(static_cast<int>(key), value);
}
}
else
canonicalizedFiles = std::move(ret.second);
- Client::AsyncLogic l(hExt, user_data, [&hExt] { return hExt->isStopped(); });
+ Client::AsyncLogic l(hExt, user_data);
l.scanFiles(*canonicalizedFiles);
auto task = std::make_shared<Task>([hExt, user_data, dir] {
EXCEPTION_ASYNC_SAFE_START(hExt->m_cb, user_data)
- Client::AsyncLogic l(hExt, user_data, [&hExt] { return hExt->isStopped(); });
+ Client::AsyncLogic l(hExt, user_data);
l.scanDir(*dir);
Client::eraseSubdirectories(*canonicalizedDirs);
- Client::AsyncLogic l(hExt, user_data, [&hExt] { return hExt->isStopped(); });
+ Client::AsyncLogic l(hExt, user_data);
l.scanDirs(*canonicalizedDirs);