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 #include <SYS/SYS_Deprecated.h>
25 
26 class OP_Node;
27 
30 {
31 public:
32  OP_CookTask(OP_Context &context, OP_Node &node)
33  : myContext(context)
34  , myNode(node)
35  , myDoneSpawning(false)
36  {
37  //myContext.setCookTask(this);
38  }
39 
40  static void
42  {
43  UT_Task *root;
44 
45  root = new (allocate_root()) OP_CookTask(context, node);
47  }
48  static OP_CookTask *
50  {
51  return new (allocate_root()) OP_CookTask(context, node);
52  }
53 
54  void
56  {
57  UT_Task *child;
58 
59  UT_ASSERT(!myDoneSpawning);
60  child = new (allocate_child()) OP_CookTask(context, node);
61  incrementRefCount();
62  spawnChild(*child);
63  }
64  void
66  {
67  // Someone is already cooking the given node. Spawn a wait task as our
68  // child. When the input is marked as done, the current task will
69  // become runnable.
70  UT_ASSERT(!myDoneSpawning);
71  incrementRefCount();
72  node.taskState().addWaitingTask(*this);
73  }
74 
75  UT_Task * run() override;
76 
77 private:
78  OP_Context myContext;
79  OP_Node & myNode;
80  bool myDoneSpawning;
81 };
83 
84 #if H_BUILD_PARALLEL_COOK_MODE
85 OP_API extern bool OPrecordSerialNodeIds;
86 OP_API extern UT_Array<int> OPserialNodeIds;
87 #endif
88 
89 #endif // __OP_COOKTASK_H_INCLUDED__
UT_TaskState & taskState()
Definition: OP_Node.h:1062
static void spawnRootAndWait(UT_Task &task)
Definition: UT_Task.h:65
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:623
#define SYS_DEPRECATED_PUSH_DISABLE()
void spawnChildTask(OP_Context &context, OP_Node &node)
Definition: OP_CookTask.h:55
#define SYS_DEPRECATED_POP_DISABLE()
static void spawnRootTaskAndWait(OP_Context &context, OP_Node &node)
Definition: OP_CookTask.h:41
OP_CookTask(OP_Context &context, OP_Node &node)
Definition: OP_CookTask.h:32
static OP_CookTask * createRootTask(OP_Context &context, OP_Node &node)
Definition: OP_CookTask.h:49
#define OP_API
Definition: OP_API.h:10
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
void addWaitingTask(UT_Task &parent_task)
Definition: UT_TaskState.h:153
void spawnWaitTask(OP_Node &node)
Definition: OP_CookTask.h:65