Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for terminating a spawned worker if a timeout is reached #207

Merged
merged 2 commits into from
Oct 6, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added documentation on the new timeout options
amit777 committed Oct 5, 2020

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 16f75093c9631bf6b59ede96f9d7b470620aa7f3
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ console.log(p.data); // prints [1, 2, 3, 4, 5]

---

### `spawn(fn)`
### `spawn(fn, opts)`

This function will spawn a new process on a worker thread. Pass it the function you want to call. Your
function will receive one argument, which is the current data. The value returned from your spawned function will
@@ -65,6 +65,8 @@ update the current data.
**Arguments**

* `fn`: A function to execute on a worker thread. Receives the wrapped data as an argument. The value returned will be assigned to the wrapped data.
* `opts`: An optional object to pass to spawn.
* 'opts.timeout': milliseconds to way for function to return value. If the worker does not finish in this time, it will be killed.

**Example**