TimestampQueryPool.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * Abstract base class of a timestamp query pool.
  3. *
  4. * @abstract
  5. */
  6. class TimestampQueryPool {
  7. /**
  8. * Creates a new timestamp query pool.
  9. *
  10. * @param {number} [maxQueries=256] - Maximum number of queries this pool can hold.
  11. */
  12. constructor( maxQueries = 256 ) {
  13. /**
  14. * Whether to track timestamps or not.
  15. *
  16. * @type {boolean}
  17. * @default true
  18. */
  19. this.trackTimestamp = true;
  20. /**
  21. * Maximum number of queries this pool can hold.
  22. *
  23. * @type {number}
  24. * @default 256
  25. */
  26. this.maxQueries = maxQueries;
  27. /**
  28. * How many queries allocated so far.
  29. *
  30. * @type {number}
  31. * @default 0
  32. */
  33. this.currentQueryIndex = 0;
  34. /**
  35. * Tracks offsets for different contexts.
  36. *
  37. * @type {Map<string, number>}
  38. */
  39. this.queryOffsets = new Map();
  40. /**
  41. * Whether the pool has been disposed or not.
  42. *
  43. * @type {boolean}
  44. * @default false
  45. */
  46. this.isDisposed = false;
  47. /**
  48. * TODO
  49. *
  50. * @type {number}
  51. * @default 0
  52. */
  53. this.lastValue = 0;
  54. /**
  55. * TODO
  56. *
  57. * @type {boolean}
  58. * @default false
  59. */
  60. this.pendingResolve = false;
  61. }
  62. /**
  63. * Allocate queries for a specific renderContext.
  64. *
  65. * @abstract
  66. * @param {Object} renderContext - The render context to allocate queries for.
  67. */
  68. allocateQueriesForContext( /* renderContext */ ) {}
  69. /**
  70. * Resolve all timestamps and return data (or process them).
  71. *
  72. * @abstract
  73. * @async
  74. * @returns {Promise<number>|number} The resolved timestamp value.
  75. */
  76. async resolveQueriesAsync() {}
  77. /**
  78. * Dispose of the query pool.
  79. *
  80. * @abstract
  81. */
  82. dispose() {}
  83. }
  84. export default TimestampQueryPool;
粤ICP备19079148号