MCPcopy Index your code
hub / github.com/gpujs/gpu.js / destroy

Method destroy

src/gpu.js:543–572  ·  view source on GitHub ↗

* @desc Destroys all memory associated with gpu.js & the webGl if we created it * @return {Promise} * @resolve {void} * @reject {Error}

()

Source from the content-addressed store, hash-verified

541 * @reject {Error}
542 */
543 destroy() {
544 return new Promise((resolve, reject) => {
545 if (!this.kernels) {
546 resolve();
547 }
548 // perform on next run loop - for some reason we dont get lose context events
549 // if webGl is created and destroyed in the same run loop.
550 setTimeout(() => {
551 try {
552 for (let i = 0; i < this.kernels.length; i++) {
553 this.kernels[i].destroy(true); // remove canvas if exists
554 }
555 // all kernels are associated with one context, go ahead and take care of it here
556 let firstKernel = this.kernels[0];
557 if (firstKernel) {
558 // if it is shortcut
559 if (firstKernel.kernel) {
560 firstKernel = firstKernel.kernel;
561 }
562 if (firstKernel.constructor.destroyContext) {
563 firstKernel.constructor.destroyContext(this.context);
564 }
565 }
566 } catch (e) {
567 reject(e);
568 }
569 resolve();
570 }, 0);
571 });
572 }
573}
574
575

Callers 15

greenCanvasFunction · 0.95
outputArrayFunction · 0.95
outputMatrixFunction · 0.95
outputCubeFunction · 0.95
outputGraphicalArrayFunction · 0.95
outputGraphicalMatrixFunction · 0.95
outputGraphicalCubeFunction · 0.95
canvasArgumentTestFunction · 0.95
inputXFunction · 0.95
inputXYFunction · 0.95
inputYXFunction · 0.95

Calls 1

destroyContextMethod · 0.45

Tested by

no test coverage detected