|
1
|
1 #pragma once
|
|
|
2 namespace fb2k {
|
|
|
3 //! pfc::splitThread() + async_task_manager::acquire
|
|
|
4 void splitTask(std::function<void()>);
|
|
|
5 void splitTask(pfc::thread::arg_t const&, std::function<void()>);
|
|
|
6 abort_callback& mainAborter();
|
|
|
7
|
|
|
8 void inCpuWorkerThread(std::function<void()> f);
|
|
|
9 }
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13 // ======================================================================================================
|
|
|
14 // Most of main_thread_callback.h declares API internals and obsolete helpers.
|
|
|
15 // In modern code, simply use fb2k::inMainThread() declared below and disregard the rest.
|
|
|
16 // ======================================================================================================
|
|
|
17 namespace fb2k {
|
|
|
18 //! Queue a call in main thread. Returns immediately. \n
|
|
|
19 //! You can call this from any thread, including main thread - to execute some code outside the current call stack / global fb2k callbacks / etc. \n
|
|
|
20 //! Guaranteed FIFO order of execution. See also: main_thread_callback::add_callback().
|
|
|
21 void inMainThread(std::function<void() > f);
|
|
|
22 //! Call f synchronously if called from main thread, queue call if called from another.
|
|
|
23 void inMainThread2(std::function<void() > f);
|
|
|
24
|
|
|
25 //! Clone abort_callback, suppress call if original abort_callback becomes set prior to reaching main thread.
|
|
|
26 void inMainThread(std::function<void() > f, abort_callback&);
|
|
|
27
|
|
|
28 //! Synchronous / abortable version. May exit *before* f() finishes, if abort becomes set.
|
|
|
29 void inMainThreadSynchronous(std::function<void() > f, abort_callback& abort);
|
|
|
30
|
|
|
31 //! Synchronous blocking version. \n
|
|
|
32 //! Uses new foobar2000 v2.0 methods if available, synchronizing to main thread via SendMessage(). \n
|
|
|
33 //! Introduced to help recovering from method-called-from-wrong-context scenarios. Does *not* guarentee FIFO execution order contrary to plain inMainThread().
|
|
|
34 void inMainThreadSynchronous2(std::function<void() > f);
|
|
|
35
|
|
|
36 //! Helper class for threads that call fb2k objects. Mainly needed for Android shims. You can safely ignore this. \n
|
|
|
37 //! Guaranteed to have startHere(), isActive() and waitTillDone() methods only.
|
|
|
38 typedef pfc::thread2 thread;
|
|
|
39 }
|