-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes: #58
- Loading branch information
Showing
8 changed files
with
321 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const Piscina = require('../..'); | ||
const { resolve } = require('path'); | ||
|
||
const pool = new Piscina({ | ||
filename: resolve(__dirname, 'worker.js'), | ||
idleTimeout: 1000 | ||
}); | ||
|
||
(async () => { | ||
// The task will transfer an ArrayBuffer | ||
// back to the main thread rather than | ||
// cloning it. | ||
const u8 = await pool.runTask(); | ||
console.log(u8.length); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const { move } = require('../..'); | ||
|
||
module.exports = () => { | ||
// Using move causes the Uint8Array to be | ||
// transferred rather than cloned. | ||
return move(new Uint8Array(10)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Piscina from '../..'; | ||
import assert from 'assert'; | ||
import { types } from 'util'; | ||
|
||
export default function (moved) { | ||
if (moved !== undefined) { | ||
assert(types.isAnyArrayBuffer(moved)); | ||
} | ||
return Piscina.move(new ArrayBuffer(10)); | ||
} |
Oops, something went wrong.