HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TIL_PriorityQueue.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: TIL_HoldingQueue.h (TIL Library, C++)
7  *
8  * COMMENTS:
9  * A 'queue' with multiple queues inside, each of which bucket a
10  * priority range.
11  */
12 #ifndef TIL_PRIORITY_QUEUE_H
13 #define TIL_PRIORITY_QUEUE_H
14 
15 #include "TIL_API.h"
16 #include "TIL_HoldingQueue.h"
17 #include <UT/UT_NonCopyable.h>
18 
20 
21 
23 {
24 public:
25 
26  // sorts nodes into 'nbuckets' queues, each of which cover
27  // consequetive priority ranges of 'bucket_range'
28  // if any bucket other than the lowest overflows the 'max_per_bucket',
29  // it will be passed down to a lower bucket.
30 
31  TIL_PriorityQueue(unsigned int nbuckets,
32  unsigned int bucket_range,
33  unsigned int max_entries);
35 
37 
38  void add(TIL_PNode *node, unsigned int priority);
39  void remove(TIL_PNode *node);
40 
41  // returns the last node in the lowest priority non-empty queue
42  TIL_PNode *pop();
43 
44  bool isEmpty() const;
45 
46  void empty(bool delete_nodes = true);
47 
48  // both of these only set the values; they only affect funture additions.
49  void setPriorityRange(unsigned int bucket_range);
50  unsigned int getPriorityRange() const { return myBucketPriority; }
51 
52  // sets the max # of elements assumed to be in the cache, so that the
53  // bucket sizes can be assigned appropriately.
54  void setMaxSize(unsigned int size);
55  unsigned int getMaxBucketSize(int bn) const { return myMaxBucketSize[bn]; }
56 
57  unsigned int getNumBuckets() const { return myNumBuckets; }
58  unsigned int getBucketSize(int bucket) const;
59 
60  int traverse(int (*tfunc)(TIL_PNode *, void *), void *data);
61 
62 private:
63  TIL_HoldingQueue *myBuckets;
64  unsigned int *myMaxBucketSize;
65  unsigned int myNumBuckets;
66  unsigned int myBucketPriority;
67 };
68 
69 #endif
unsigned int getNumBuckets() const
unsigned int getPriorityRange() const
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
unsigned int getMaxBucketSize(int bn) const
GLsizeiptr size
Definition: glcorearb.h:664
TIL_HoldingNode TIL_PNode
GU_API ComputeHierarchyResult traverse(const GU_Detail *gdp, GA_OffsetArray &roots, GA_OffsetArray &nodes, GA_OffsetArray &parents, UT_Map< GA_Offset, GA_OffsetArray > *children=nullptr)
ImageBuf OIIO_API add(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
#define TIL_API
Definition: TIL_API.h:10
Definition: format.h:895