MCPcopy Create free account
hub / github.com/sparkjsdev/spark / driveSort

Method driveSort

src/OldSparkViewpoint.ts:536–563  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

534 }
535
536 private async driveSort() {
537 while (true) {
538 if (this.sorting || !this.pending) {
539 return; // Sort already in process or nothing to sort
540 }
541
542 const { viewToWorld, displayed } = this.pending;
543 let accumulator = this.pending.accumulator;
544 if (!accumulator) {
545 // Hold a reference to the accumulator while sorting
546 accumulator = this.display?.accumulator ?? this.spark.active;
547 accumulator.refCount += 1;
548 }
549 this.pending = null;
550 if (!accumulator) {
551 throw new Error("No accumulator to sort");
552 }
553
554 this.sorting = { viewToWorld };
555 await this.sortUpdate({ accumulator, viewToWorld, displayed });
556 this.sorting = null;
557
558 // Release the reference to the accumulator
559 this.spark.releaseAccumulator(accumulator);
560
561 // Continue in loop with any queued sort
562 }
563 }
564
565 private async sortUpdate({
566 accumulator,

Callers 1

autoPollMethod · 0.95

Calls 2

sortUpdateMethod · 0.95
releaseAccumulatorMethod · 0.80

Tested by

no test coverage detected