All Projects → nodenative → nodenative

nodenative / nodenative

Licence: MIT license
C++14 port for the Node.js: native performance and modern simplicity

Programming Languages

C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to nodenative

Node.pas
Asynchronous Event-driven server programming for EMB Delphi, powered by libuv.
Stars: ✭ 45 (+200%)
Mutual labels:  promises, libuv
proposal-symbol-thenable
gus.host/proposal-symbol-thenable
Stars: ✭ 18 (+20%)
Mutual labels:  promises
node-pg-large-object
Large object support for PostgreSQL clients using the node-postgres library.
Stars: ✭ 31 (+106.67%)
Mutual labels:  promises
hive-desktop
🐝 A small LAN chat app
Stars: ✭ 69 (+360%)
Mutual labels:  libuv
nysocks
Nysocks binds kcp and libuv to provide an aggressive tcp tunnel in nodejs.
Stars: ✭ 78 (+420%)
Mutual labels:  libuv
Javascript-Interview-Preparation
A curated collection of javascript interview questions & solutions.
Stars: ✭ 163 (+986.67%)
Mutual labels:  promises
thhp
Very Fast HTTP Parser
Stars: ✭ 14 (-6.67%)
Mutual labels:  http-parser
jq-ajax-progress
jQuery plugin that adds support of `progress` promise
Stars: ✭ 59 (+293.33%)
Mutual labels:  promises
jwEngine
A cross-platform C++<->lua server quick solution
Stars: ✭ 226 (+1406.67%)
Mutual labels:  libuv
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (+33.33%)
Mutual labels:  promises
Microfutures
Lightweight implementation of Futures that shares a similar subscription interface with RxSwift.
Stars: ✭ 38 (+153.33%)
Mutual labels:  promises
bproxy
high-performance minimal HTTP reverse proxy
Stars: ✭ 28 (+86.67%)
Mutual labels:  libuv
flush-promises
Flush all queued resolved promise handlers
Stars: ✭ 172 (+1046.67%)
Mutual labels:  promises
node-pagerduty
⛔️ DEPRECATED - PagerDuty v2 API Wrapper for Node
Stars: ✭ 19 (+26.67%)
Mutual labels:  promises
httpparser
HTTP request, response and urls parser
Stars: ✭ 69 (+360%)
Mutual labels:  http-parser
storage
Extend the Chrome Extension Storage API with Promises and great TypeScript support.
Stars: ✭ 48 (+220%)
Mutual labels:  promises
vue-promise-dialogs
A tiny & modern library that allows you to work with dialogs as with asynchronous functions.
Stars: ✭ 43 (+186.67%)
Mutual labels:  promises
async-airtable
A lightweight npm package to handle working with the Airtable API.
Stars: ✭ 48 (+220%)
Mutual labels:  promises
combine-promises
Like Promise.all(array) but with an object instead of an array.
Stars: ✭ 181 (+1106.67%)
Mutual labels:  promises
future.callr
🚀 R package future.callr: A Future API for Parallel Processing using 'callr'
Stars: ✭ 52 (+246.67%)
Mutual labels:  promises

nodenative

nodenative is a C++14 (aka C++1y) port for node.js. This is alive project of d5's node.native changed considerably for better maintenance.

Linux and OSX Coverage Status

Please note that nodenative project is under heavy development.

Feature highlights

  • Basic functionality of Promise/A+ based on event pool (native::Promise<R>, native::Future<R>, native::async(F, Args...)). A Future callback may return a future object.
  • Thread pool (native::worker(F, Args...))
  • TCP protocol (native::net::Tcp)
  • HTTP server integrated with ServerPlugin and asynchronous callbacks (native::Future<void>)
  • HTTP client (native::http::get())
  • File System I/O (native::fs)
  • Timer (native::Timer)

Sample code

An web-server example using asynchronous callback.

#include <iostream>
#include <native/native.hpp>

using namespace native;
using namespace http;

int main() {                                                                                                                                                                                                                             std::shared_ptr<Loop> loop = Loop::Create();
  std::shared_ptr<Server> server = Server::Create(loop);
  server->get("/", [](std::shared_ptr<ServerConnection> connection) -> Future<void> {
    // some initial work on the main thread
    std::weak_ptr<ServerConnection> connectionWeak = connection;

    ServerResponse &res = connection->getResponse();
    res.setStatus(200);
    res.setHeader("Content-Type", "text/plain");

    // wait... I have some async work too. I will update you when I'm done.
    return worker([]() {
             // Some work on the thread pool to keep the main thread free
             std::chrono::milliseconds time(2000);
             std::this_thread::sleep_for(time);
           })
        .then([]() {
          // and some work on the main thread to sync data and avoid race condition
          std::chrono::milliseconds time(100);
          std::this_thread::sleep_for(time);
        })
        .finally([connectionWeak]() {
          // in the end send the response.
          connectionWeak.lock()->getResponse().end("C++ FTW\n");
        });
  });

  server->onError([](const Error &err) { std::cout << "error name: " << err.name(); });

  if (!server->listen("0.0.0.0", 8080)) {
    std::cout << "cannot start server. Check the port 8080 if it is free.\n";
    return 1; // Failed to run server.
  }

  std::cout << "Server running at http://0.0.0.0:8080/" << std::endl;
  return run();
}

Getting started

nodenative requires libuv and http-parser lib to use.

Documentation

Build code

To compile included sample application(webserver.cpp) first run the following command in the project directory:

git submodule update --init

then generate the build files and compile:

./build.py
make -C out

build.py will try to download build dependencies (gyp) if missing. If you prefer to download manually you can do:

$ git clone https://chromium.googlesource.com/external/gyp.git build/gyp

OR

$ svn co http://gyp.googlecode.com/svn/trunk build/gyp

By default will try to generate ninja file if possible, alternatively make file. After it will build in Debug and Release mode. If you want to generate for a specific build tool use -f <buildtool>. e.x:

./build.py -f ninja
ninja -C out/Debug/

alternatively you can set custom paths to http-parser and libuv if you dont want to use the submodules. If it is build with make in debug mode, then executables are saved to out/Debug dir.

Build documentation

To build documentation just run the doxygen doxyfile command from the project root. The result document will be generated into ./out/doc/ path.

Run samples

In samples dir you can see samples which use native library.

To run webserver sample compiled by make in debug mode:

out/Debug/webserver

Run tests

To run tests compiled by make in debug mode:

out/Debug/test

Tested on

  • Linux with GCC 5.3.0.
  • OSX 10.10.2 with xcode7
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].