HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OP_CookTask.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: OP_CookTash.h (OP Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __OP_COOKTASK_H_INCLUDED__
12 #define __OP_COOKTASK_H_INCLUDED__
13 
14 #include "OP_API.h"
15 #include "OP_Error.h"
16 #include "OP_Node.h"
17 
18 #include <UT/UT_Assert.h>
19 #include <UT/UT_Debug.h>
20 #include <UT/UT_Thread.h>
21 #include <UT/UT_Task.h>
22 #include <UT/UT_TaskState.h>
23 
24 class OP_Node;
25 
26 class OP_API OP_CookTask : public UT_Task
27 {
28 public:
29  OP_CookTask(OP_Context &context, OP_Node &node)
30  : myContext(context)
31  , myNode(node)
32  , myDoneSpawning(false)
33  {
34  myContext.setCookTask(this);
35  }
36 
37  static void
39  {
40  UT_Task *root;
41 
42  root = new (allocate_root()) OP_CookTask(context, node);
44  }
45  static OP_CookTask *
47  {
48  return new (allocate_root()) OP_CookTask(context, node);
49  }
50 
51  void
53  {
54  UT_Task *child;
55 
56  UT_ASSERT(!myDoneSpawning);
57  child = new (allocate_child()) OP_CookTask(context, node);
59  spawnChild(*child);
60  }
61  void
63  {
64  // Someone is already cooking the given node. Spawn a wait task as our
65  // child. When the input is marked as done, the current task will
66  // become runnable.
67  UT_ASSERT(!myDoneSpawning);
69  node.taskState().addWaitingTask(*this);
70  }
71 
72  virtual UT_Task * run();
73 
74 private:
75  OP_Context myContext;
76  OP_Node & myNode;
77  bool myDoneSpawning;
78 };
79 
80 #endif // __OP_COOKTASK_H_INCLUDED__
UT_TaskState & taskState()
Definition: OP_Node.h:1029
static void spawnRootAndWait(UT_Task &task)
Definition: UT_Task.h:58
void spawnChildTask(OP_Context &context, OP_Node &node)
Definition: OP_CookTask.h:52
static void spawnRootTaskAndWait(OP_Context &context, OP_Node &node)
Definition: OP_CookTask.h:38
OP_CookTask(OP_Context &context, OP_Node &node)
Definition: OP_CookTask.h:29
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:102
static OP_CookTask * createRootTask(OP_Context &context, OP_Node &node)
Definition: OP_CookTask.h:46
void incrementRefCount()
Definition: UT_Task.h:40
void spawnChild(UT_Task &task)
Definition: UT_Task.h:68
virtual UT_Task * run()=0
#define OP_API
Definition: OP_API.h:10
void addWaitingTask(UT_Task &parent_task)
Definition: UT_TaskState.h:103
void spawnWaitTask(OP_Node &node)
Definition: OP_CookTask.h:62