HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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_Array.h>
19 #include <UT/UT_Assert.h>
20 #include <UT/UT_Debug.h>
21 #include <UT/UT_Thread.h>
22 #include <UT/UT_Task.h>
23 #include <UT/UT_TaskState.h>
24 
25 class OP_Node;
26 
27 class OP_API OP_CookTask : public UT_Task
28 {
29 public:
31  : myContext(context)
32  , myNode(node)
33  , myDoneSpawning(false)
34  {
35  myContext.setCookTask(this);
36  }
37 
38  static void
40  {
41  UT_Task *root;
42 
43  root = new (allocate_root()) OP_CookTask(context, node);
45  }
46  static OP_CookTask *
48  {
49  return new (allocate_root()) OP_CookTask(context, node);
50  }
51 
52  void
54  {
55  UT_Task *child;
56 
57  UT_ASSERT(!myDoneSpawning);
58  child = new (allocate_child()) OP_CookTask(context, node);
60  spawnChild(*child);
61  }
62  void
64  {
65  // Someone is already cooking the given node. Spawn a wait task as our
66  // child. When the input is marked as done, the current task will
67  // become runnable.
68  UT_ASSERT(!myDoneSpawning);
70  node.taskState().addWaitingTask(*this);
71  }
72 
73  virtual UT_Task * run();
74 
75 private:
76  OP_Context myContext;
77  OP_Node & myNode;
78  bool myDoneSpawning;
79 };
80 
81 #if H_BUILD_PARALLEL_COOK_MODE
82 OP_API extern bool OPrecordSerialNodeIds;
83 OP_API extern UT_Array<int> OPserialNodeIds;
84 #endif
85 
86 #endif // __OP_COOKTASK_H_INCLUDED__
UT_TaskState & taskState()
Definition: OP_Node.h:1055
static void spawnRootAndWait(UT_Task &task)
Definition: UT_Task.h:58
void spawnChildTask(OP_Context &context, OP_Node &node)
Definition: OP_CookTask.h:53
static void spawnRootTaskAndWait(OP_Context &context, OP_Node &node)
Definition: OP_CookTask.h:39
OP_CookTask(OP_Context &context, OP_Node &node)
Definition: OP_CookTask.h:30
static OP_CookTask * createRootTask(OP_Context &context, OP_Node &node)
Definition: OP_CookTask.h:47
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
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:135
void addWaitingTask(UT_Task &parent_task)
Definition: UT_TaskState.h:148
void spawnWaitTask(OP_Node &node)
Definition: OP_CookTask.h:63