DYT/Tool/matlab/include/MatlabCppSharedLib/detail/task_reference_impl.hpp

31 lines
1.0 KiB
C++
Raw Permalink Normal View History

2024-11-22 15:19:31 +00:00
/* Copyright 2017 The MathWorks, Inc. */
#ifndef TASK_REFERENCE_IMPL_HPP
#define TASK_REFERENCE_IMPL_HPP
#include <MatlabExecutionInterface/task_reference.hpp>
namespace matlab {
namespace execution {
inline TaskReference::TaskReference() {};
inline TaskReference::TaskReference(std::function<bool(uintptr_t, bool)>&& cancel)
:handle(0),cancelImpl(std::move(cancel)){};
inline TaskReference::TaskReference(uintptr_t aHandle, std::function<bool(uintptr_t, bool)>&& cancel)
:handle(aHandle), cancelImpl(std::move(cancel)) {};
inline uintptr_t TaskReference::getHandle() const
{
return handle;
}
inline TaskReference::~TaskReference()
{
if(handle) cppsharedlib_destroy_task_handle(handle);
};
inline bool TaskReference::cancel(bool allowInterrupt)
{
return cancelImpl(handle, allowInterrupt);
}
}
}
#endif //TASK_REFERENCE_IMPL_HPP