|
Packit |
b5b901 |
Introduction
|
|
Packit |
b5b901 |
============
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
This 'book' is a small set of tutorials about using libuv_ as
|
|
Packit |
b5b901 |
a high performance evented I/O library which offers the same API on Windows and Unix.
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
It is meant to cover the main areas of libuv, but is not a comprehensive
|
|
Packit |
b5b901 |
reference discussing every function and data structure. The `official libuv
|
|
Packit |
b5b901 |
documentation`_ may be consulted for full details.
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
.. _official libuv documentation: http://docs.libuv.org/en/v1.x/
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
This book is still a work in progress, so sections may be incomplete, but
|
|
Packit |
b5b901 |
I hope you will enjoy it as it grows.
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
Who this book is for
|
|
Packit |
b5b901 |
--------------------
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
If you are reading this book, you are either:
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
1) a systems programmer, creating low-level programs such as daemons or network
|
|
Packit |
b5b901 |
services and clients. You have found that the event loop approach is well
|
|
Packit |
b5b901 |
suited for your application and decided to use libuv.
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
2) a node.js module writer, who wants to wrap platform APIs
|
|
Packit |
b5b901 |
written in C or C++ with a set of (a)synchronous APIs that are exposed to
|
|
Packit |
b5b901 |
JavaScript. You will use libuv purely in the context of node.js. For
|
|
Packit |
b5b901 |
this you will require some other resources as the book does not cover parts
|
|
Packit |
b5b901 |
specific to v8/node.js.
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
This book assumes that you are comfortable with the C programming language.
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
Background
|
|
Packit |
b5b901 |
----------
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
The node.js_ project began in 2009 as a JavaScript environment decoupled
|
|
Packit |
b5b901 |
from the browser. Using Google's V8_ and Marc Lehmann's libev_, node.js
|
|
Packit |
b5b901 |
combined a model of I/O -- evented -- with a language that was well suited to
|
|
Packit |
b5b901 |
the style of programming; due to the way it had been shaped by browsers. As
|
|
Packit |
b5b901 |
node.js grew in popularity, it was important to make it work on Windows, but
|
|
Packit |
b5b901 |
libev ran only on Unix. The Windows equivalent of kernel event notification
|
|
Packit |
b5b901 |
mechanisms like kqueue or (e)poll is IOCP. libuv was an abstraction around libev
|
|
Packit |
b5b901 |
or IOCP depending on the platform, providing users an API based on libev.
|
|
Packit |
b5b901 |
In the node-v0.9.0 version of libuv `libev was removed`_.
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
Since then libuv has continued to mature and become a high quality standalone
|
|
Packit |
b5b901 |
library for system programming. Users outside of node.js include Mozilla's
|
|
Packit |
b5b901 |
Rust_ programming language, and a variety_ of language bindings.
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
This book and the code is based on libuv version `v1.3.0`_.
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
Code
|
|
Packit |
b5b901 |
----
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
All the code from this book is included as part of the source of the book on
|
|
Packit |
b5b901 |
Github. `Clone`_/`Download`_ the book, then build libuv::
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
cd libuv
|
|
Packit |
b5b901 |
./autogen.sh
|
|
Packit |
b5b901 |
./configure
|
|
Packit |
b5b901 |
make
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
There is no need to ``make install``. To build the examples run ``make`` in the
|
|
Packit |
b5b901 |
``code/`` directory.
|
|
Packit |
b5b901 |
|
|
Packit |
b5b901 |
.. _Clone: https://github.com/nikhilm/uvbook
|
|
Packit |
b5b901 |
.. _Download: https://github.com/nikhilm/uvbook/downloads
|
|
Packit |
b5b901 |
.. _v1.3.0: https://github.com/libuv/libuv/tags
|
|
Packit Service |
e08953 |
.. _V8: https://v8.dev
|
|
Packit |
b5b901 |
.. _libev: http://software.schmorp.de/pkg/libev.html
|
|
Packit |
b5b901 |
.. _libuv: https://github.com/libuv/libuv
|
|
Packit Service |
e08953 |
.. _node.js: https://www.nodejs.org
|
|
Packit |
b5b901 |
.. _libev was removed: https://github.com/joyent/libuv/issues/485
|
|
Packit Service |
e08953 |
.. _Rust: https://www.rust-lang.org
|
|
Packit |
b5b901 |
.. _variety: https://github.com/libuv/libuv/wiki/Projects-that-use-libuv
|