14 namespace mt {
template<>
struct is_base_of<
honey::priv::SharedObj_tag, DepTask> : std::true_type {}; }
17 class DepTask :
public SharedObj<DepTask>, thread::Pool::Task
25 typedef function<void ()>
Func;
59 operator const Id&()
const {
return getId(); }
76 virtual void exec() = 0;
106 template<
class Result>
129 virtual void exec() { _func.invoke_delayedReady(); }
130 virtual void resetFunctor() { _func.setReady(
true); }
132 PackagedTask<Result ()> _func;
182 bool enqueue_priv(
DepTask& task);
186 vector<DepTask*> _taskStack;
A scoped lock that references any lockable. Locks on construction and unlocks on destruction.
Definition: Mutex.h:10
DepTask(const Id &id)
Definition: DepTask.cpp:15
static mt_global(DepSched, inst,(future::AsyncSched::inst()))
Get singleton, uses global future::AsyncSched pool.
Atomic< State > _state
Definition: DepTask.h:89
Unique future, guarantees sole access to a future function result.
Definition: Future.h:53
Thread class.
Definition: Thread.h:128
DepGraph::Vertex * _vertex
Definition: DepTask.h:99
const Id & getId() const
Definition: DepTask.h:49
Combined intrusive/non-intrusive smart pointer. Can reference and share any object automatically...
Definition: SharedPtr.h:175
SharedPtr< DepTask_ > Ptr
Definition: DepTask.h:110
Thread * _thread
Definition: DepTask.h:101
String info() const
Get task info for prepending to a log record.
Definition: DepTask.cpp:134
SharedPtr< DepTask > Ptr
Definition: DepTask.h:24
int _priority
Definition: DepTask.h:102
static bool trace
Whether to log task execution flow.
Definition: DepTask.h:178
Waiting for upstream tasks (dependency subgraph) to complete.
WeakPtr< DepTask > _root
Definition: DepTask.h:92
static AsyncSched & inst()
Definition: Util.h:153
int _depDownWaitInit
Definition: DepTask.h:97
void setPriority(int priority)
Set thread execution scheduling priority.
Definition: Thread.h:185
Base class of DepTask_, can be added to scheduler. Instances must be created through class DepTask_...
Definition: DepTask.h:18
static DepTask & current()
Get the current task object. Must be called from a task functor.
Definition: DepTask.cpp:32
int _bindId
Definition: DepTask.h:93
void interrupt(const Exception::ConstPtr &e=new thread::Interrupted)
Request an interrupt in the executing task's thread.
Definition: DepTask.h:38
Atomic< int > _depDownWait
Definition: DepTask.h:98
static auto _
Definition: Module.cpp:8
bool enqueue(DepTask &task)
Schedule a task for execution. Returns false if task is already active.
Definition: DepTask.cpp:275
DepGraph< DepTask::DepNode > DepGraph
Definition: DepTask.h:27
DepSched * _sched
Definition: DepTask.h:91
Future< Result > future()
Get future from which delayed result can be retrieved.
Definition: DepTask.h:123
Mutex _lock
Definition: DepTask.h:88
void bindDirty()
Definition: DepTask.cpp:39
virtual bool traceEnabled() const
Definition: DepTask.h:191
DepNode & deps()
Get dependency node. Upstream and downstream tasks can be specified through the node.
Definition: DepTask.h:56
int _depUpWaitInit
Definition: DepTask.h:95
virtual void resetFunctor()=0
bool _bindDirty
Definition: DepTask.h:94
virtual void trace(const String &file, int line, const String &msg) const
Definition: DepTask.cpp:139
State
Definition: DepTask.h:65
Atomic< int > _depUpWait
Definition: DepTask.h:96
virtual ~DepTask()
Definition: DepTask.h:29
bool unreg(DepTask &task)
Unregister a task. Returns false if not registered.
Definition: DepTask.cpp:172
#define assert(...)
Forwards to assert_#args. See assert_1(), assert_2().
Definition: Debug.h:24
#define idnull
Null id.
Definition: Id.h:124
Unicode UTF-16 string class, wrapper around std::u16string.
Definition: String.h:23
bool reg(DepTask &task)
Register a task, linking it into this scheduler's dependency graph.
Definition: DepTask.cpp:152
int _regCount
Definition: DepTask.h:90
Interrupted exception.
Definition: Thread.h:101
void setPriority(int priority)
Set task's thread execution scheduling priority.
Definition: DepTask.h:43
A vertex is initially associated with one key and acts like a multi-map, storing all nodes and graph ...
Definition: Dep.h:107
bool active() const
Check if task is in queue or executing.
Definition: DepTask.h:35
function< void()> Func
Definition: DepTask.h:25
bool interruptRequested()
Check whether an interrupt has been requested for the executing task's thread.
Definition: DepTask.h:40
void setId(const Id &id)
Set id used for dependency graph and debug output.
Definition: DepTask.h:48
Waiting for downsteam tasks (immediate dependees) to complete.
bool _onStack
Definition: DepTask.h:100
void interrupt(const Exception::ConstPtr &e=new thread::Interrupted)
Request an interrupt in the thread.
Definition: Thread.cpp:156
DepSched(thread::Pool &pool)
Definition: DepTask.cpp:148
A thread lock where the lock is acquired by suspending thread execution until it becomes available...
Definition: Mutex.h:17
const Key & getKey() const
Definition: Dep.h:46
void operator()()
Definition: DepTask.cpp:47
Scheduler that serializes and parallelizes task execution given a dependency graph of tasks and a poo...
Definition: DepTask.h:139
Holds a name string and its hashed value for fast comparison ops. See String Identifier.
Definition: Id.h:25
static DepTask_ & current()
Wrapper for DepTask::current()
Definition: DepTask.h:126
void finalize_()
Clean up task after execution.
Definition: DepTask.cpp:123
Point to a shared object without holding a reference. The object is accessible through a lock...
Definition: SharedPtr.h:165
DepNode< DepTask * > DepNode
Definition: DepTask.h:26
bool interruptRequested() const
Check whether an interrupt has been requested for the thread.
Definition: Thread.cpp:167
DepTask_(Func &&f, const Id &id=idnull)
Definition: DepTask.h:117
void setKey(const Key &key)
Set the key used to identify this node.
Definition: Dep.h:45
Global Honeycomb namespace.
DepNode _depNode
Definition: DepTask.h:87
int getPriority() const
Get task's thread execution scheduling priority.
Definition: DepTask.h:45
Holds a functor and dependency information, enqueue in a scheduler to run the task.
Definition: DepTask.h:107
Spreads task execution across a pool of re-usable threads. Uses a lock-free work-stealing queue to en...
Definition: Pool.h:12