1e66f31c5Sopenharmony_ciIntroduction
2e66f31c5Sopenharmony_ci============
3e66f31c5Sopenharmony_ci
4e66f31c5Sopenharmony_ciThis 'book' is a small set of tutorials about using libuv_ as
5e66f31c5Sopenharmony_cia high performance evented I/O library which offers the same API on Windows and Unix.
6e66f31c5Sopenharmony_ci
7e66f31c5Sopenharmony_ciIt is meant to cover the main areas of libuv, but is not a comprehensive
8e66f31c5Sopenharmony_cireference discussing every function and data structure. The `official libuv
9e66f31c5Sopenharmony_cidocumentation`_ may be consulted for full details.
10e66f31c5Sopenharmony_ci
11e66f31c5Sopenharmony_ci.. _official libuv documentation: https://docs.libuv.org/en/v1.x/
12e66f31c5Sopenharmony_ci
13e66f31c5Sopenharmony_ciThis book is still a work in progress, so sections may be incomplete, but
14e66f31c5Sopenharmony_ciI hope you will enjoy it as it grows.
15e66f31c5Sopenharmony_ci
16e66f31c5Sopenharmony_ciWho this book is for
17e66f31c5Sopenharmony_ci--------------------
18e66f31c5Sopenharmony_ci
19e66f31c5Sopenharmony_ciIf you are reading this book, you are either:
20e66f31c5Sopenharmony_ci
21e66f31c5Sopenharmony_ci1) a systems programmer, creating low-level programs such as daemons or network
22e66f31c5Sopenharmony_ci   services and clients. You have found that the event loop approach is well
23e66f31c5Sopenharmony_ci   suited for your application and decided to use libuv.
24e66f31c5Sopenharmony_ci
25e66f31c5Sopenharmony_ci2) a node.js module writer, who wants to wrap platform APIs
26e66f31c5Sopenharmony_ci   written in C or C++ with a set of (a)synchronous APIs that are exposed to
27e66f31c5Sopenharmony_ci   JavaScript. You will use libuv purely in the context of node.js. For
28e66f31c5Sopenharmony_ci   this you will require some other resources as the book does not cover parts
29e66f31c5Sopenharmony_ci   specific to v8/node.js.
30e66f31c5Sopenharmony_ci
31e66f31c5Sopenharmony_ciThis book assumes that you are comfortable with the C programming language.
32e66f31c5Sopenharmony_ci
33e66f31c5Sopenharmony_ciBackground
34e66f31c5Sopenharmony_ci----------
35e66f31c5Sopenharmony_ci
36e66f31c5Sopenharmony_ciThe node.js_ project began in 2009 as a JavaScript environment decoupled
37e66f31c5Sopenharmony_cifrom the browser. Using Google's V8_ and Marc Lehmann's libev_, node.js
38e66f31c5Sopenharmony_cicombined a model of I/O -- evented -- with a language that was well suited to
39e66f31c5Sopenharmony_cithe style of programming; due to the way it had been shaped by browsers. As
40e66f31c5Sopenharmony_cinode.js grew in popularity, it was important to make it work on Windows, but
41e66f31c5Sopenharmony_cilibev ran only on Unix. The Windows equivalent of kernel event notification
42e66f31c5Sopenharmony_cimechanisms like kqueue or (e)poll is IOCP. libuv was an abstraction around libev
43e66f31c5Sopenharmony_cior IOCP depending on the platform, providing users an API based on libev.
44e66f31c5Sopenharmony_ciIn the node-v0.9.0 version of libuv `libev was removed`_.
45e66f31c5Sopenharmony_ci
46e66f31c5Sopenharmony_ciSince then libuv has continued to mature and become a high quality standalone
47e66f31c5Sopenharmony_cilibrary for system programming. Users outside of node.js include Mozilla's
48e66f31c5Sopenharmony_ciRust_ programming language, and a variety_ of language bindings.
49e66f31c5Sopenharmony_ci
50e66f31c5Sopenharmony_ciThis book and the code is based on libuv version `v1.42.0`_.
51e66f31c5Sopenharmony_ci
52e66f31c5Sopenharmony_ciCode
53e66f31c5Sopenharmony_ci----
54e66f31c5Sopenharmony_ci
55e66f31c5Sopenharmony_ciAll the example code and the source of the book is included as part of
56e66f31c5Sopenharmony_cithe libuv_ project on GitHub.
57e66f31c5Sopenharmony_ciClone or Download libuv_, then build it::
58e66f31c5Sopenharmony_ci
59e66f31c5Sopenharmony_ci    sh autogen.sh
60e66f31c5Sopenharmony_ci    ./configure
61e66f31c5Sopenharmony_ci    make
62e66f31c5Sopenharmony_ci
63e66f31c5Sopenharmony_ciThere is no need to ``make install``. To build the examples run ``make`` in the
64e66f31c5Sopenharmony_ci``docs/code/`` directory.
65e66f31c5Sopenharmony_ci
66e66f31c5Sopenharmony_ci.. _v1.42.0: https://github.com/libuv/libuv/releases/tag/v1.42.0
67e66f31c5Sopenharmony_ci.. _V8: https://v8.dev
68e66f31c5Sopenharmony_ci.. _libev: http://software.schmorp.de/pkg/libev.html
69e66f31c5Sopenharmony_ci.. _libuv: https://github.com/libuv/libuv
70e66f31c5Sopenharmony_ci.. _node.js: https://www.nodejs.org
71e66f31c5Sopenharmony_ci.. _libev was removed: https://github.com/joyent/libuv/issues/485
72e66f31c5Sopenharmony_ci.. _Rust: https://www.rust-lang.org
73e66f31c5Sopenharmony_ci.. _variety: https://github.com/libuv/libuv/blob/v1.x/LINKS.md
74