nodejs / abi-stable-node

Repository used by the Node-API team to manage work related to Node-API and node-addon-api
241 stars 34 forks source link

Possible chances to take advantage of libuv stability #361

Open ghinks opened 5 years ago

ghinks commented 5 years ago

Possible chances to take advantage of libuv stability

Use of libuv polling for the more hardware orientated modules is being seen.

Use is being made of libuv to detect events on a file descriptor in existing stable modules. Some of the features that libuv provide could be exposed via NAPI or use of libuv could be allowed in order to avoid complex changes to some modules.

modules looked at that support these cases

github repo description npm wkly downloads thousands
node-serialport arduino serial port driver allowing educational and hoby 23
node-raw-socket module used by net-ping for JS ping utilities 433

Code fragement example

void Poller::poll(int events) {
  this->events = this->events | events;
  int status = uv_poll_start(poll_handle, events, Poller::onData);
  if (0 != status) {
    ...
    return;
  }
}

Code line links

reconbot commented 5 years ago

I would love to see this. uv_poll_t is very useful and not very complex.

gabrielschulhof commented 5 years ago

@cjihrig in the event of a libuv-2.0 release, is there danger of the polling API suffering an ABI break?

cjihrig commented 5 years ago

Not that I'm aware of, but I'm going to ping @bnoordhuis just in case.