Skip to content

Example app showing how to run background tasks in neon which communicate asynchronously with node.js

Notifications You must be signed in to change notification settings

rebo/async-neon-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neon-async-example

An example app showing up to setup neon so that a background Rust task can get data aynschonously from Node.js.

The control flow is this..

Node.js invokes "perform_async_task" from index.rs

That task schedules two Neon Tasks a Dispatch task and MainBackgroundTask task.

The DispatchTask blocks until it receives a signal from MainBackgroundTask. (*)

When the MainBackgroundTask needs more data it unblocks the DispatchTask which then completes.

The completed Dispatch task gets new data from Node.js, sends this to the MainBackgroundTask, and then reschedules itself blocking again.

The main background task completes until it needs more data,(Step * above)

Notes:

This makes use of the PersistentHandle pull request because you need to send 'boxed' jsHandles to your Dispatch and MainBackgroundTasks.

Hence you need to point to your own neon-bindings build, as demonstrated in Cargo.toml

See: neon-bindings/neon#284

About

Example app showing how to run background tasks in neon which communicate asynchronously with node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published