12 #ifndef __UT_HOUDINIEXECUTIONCONTEXT_H__
13 #define __UT_HOUDINIEXECUTIONCONTEXT_H__
31 virtual ~
Event() =
default;
44 void invoke()
override { myFunc(); }
66 return theInstance !=
nullptr;
95 theInstance =
nullptr;
119 hboost::asio::post(myIOContext, [
event = std::move(ev)]()
137 void run(exception_handler_t exception_handler =
nullptr);
140 myIOContext.restart();
164 myLoop.postEvent(std::move(ev));
177 : myCtx(std::addressof(context))
185 UI_QtExecutionContext&
query(hboost::asio::execution::detail::context_t)
const
190 static constexpr hboost::asio::execution::blocking_t
query(
191 hboost::asio::execution::blocking_t)
193 return hboost::asio::execution::blocking.never;
196 static constexpr hboost::asio::exection::relationship_t
query(
197 hboost::asio::execution::relationship_t)
199 return hboost::asio::execution::relationship.fork;
202 static constexpr hboost::asio::execution::outstanding_work_t
query(
203 hboost::asio::execution::outstanding_work_t)
205 return hboost::asio::execution::outstanding_work.tracked;
208 template <
typename OtherAllocator>
209 static constexpr
auto query(
210 hboost::asio::execution::allocator_t<OtherAllocator>)
212 return std::allocator<void>();
215 static constexpr
auto query(hboost::asio::execution::allocator_t<void>)
217 return std::allocator<void>();
220 template <
typename F>
223 myCtx->execute(std::move(f));
230 template <
typename F,
typename OtherAllocator>
235 template <
typename F,
typename OtherAllocator>
236 void post(F f,
const OtherAllocator&
a)
const
240 template <
typename F,
typename OtherAllocator>
241 void defer(F f,
const OtherAllocator&
a)
const
245 template <
typename F>
248 myCtx->
post(std::move(f));
254 return myCtx == rhs.myCtx;
265 #endif // __UT_HOUDINIEXECUTIONCONTEXT_H__
static void clearInstance()
void defer(F f, const OtherAllocator &a) const
UT_HoudiniEventLoopExecutionContext()
GLsizei const GLfloat * value
UT_HoudiniExecutionContext & context()
GLboolean GLboolean GLboolean GLboolean a
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
bool(*)(std::exception_ptr) exception_handler_t
UT_HoudiniExecutionContext()
void post_(UT_UniquePtr< Event > ev) override
bool operator==(const UT_HoudiniExecutor &rhs) const
bool operator!=(const UT_HoudiniExecutor &rhs) const
UT_HoudiniWorkEventLoop()
void postEvent(UT_UniquePtr< event_t > ev)
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
static bool hasInstance()
UT_UniquePtr< T > UTmakeUnique(REST &&...args)
hboost::asio::io_context ASIO_IOContext
UT_HoudiniWorkEventLoop & loop()
virtual void onWorkStarted()
void post(F f, const OtherAllocator &a) const
LeafData & operator=(const LeafData &)=delete
static UT_HoudiniExecutionContext * instance()
void dispatch(F f, const OtherAllocator &a) const
void on_work_finished() const
virtual void onWorkFinished()
void on_work_started() const
UT_HoudiniExecutor(UT_HoudiniExecutionContext &context)
int invoke(const Func &taskFunc1, Rest...taskFuncN)