libuv 介紹


Cross-platform asynchronous I/O

背景:
特別說明的是libev 中包含了libevent 的內容,而libuv從libev修改而來。
node.js 最初發起於 2009 年, 是一個可以讓 Javascript 代碼脫離瀏覽器的執行環境, libuv 使用了 Google 的 V8 執行引擎 和 Marc Lehmann 的 libev. Node.js 將事件驅動的 I/O 模型與適合該模型的編程語言(Javascript)融合在了一起, 隨着 node.js 的日益流行, node.js 的開發者們也意識到應該讓 node.js 在 Windows 平台下也能工作, 但是 libev 只能在 Unix 環境下運行. Windows 平台上與 kqueue(FreeBSD) 或者 (e)poll(Linux) 等內核事件通知相應的機制 是 IOCP, libuv 依據不同平台的特性(Unix 平台為 libev, Windows 平台為 IOCP) 給上層應用提供了統一基於 libev API 的抽象, 不過 node-v0.9.0 版本的 libuv 中 libev 的依賴已被移除, 參見: libev has been removed libuv 直接與 Unix 平台交互.

詳情見下面 書籍 《 An Introduction to libuv》的序言


libuv官方網站
libuv官方github

Overview

libuv is a multi-platform support library with a focus on asynchronous I/O. It was primarily developed for use by Node.js, but it’s also used by Luvit, Julia, pyuv, and others.

Features

  • Full-featured event loop backed by epoll, kqueue, IOCP, event ports.
  • Asynchronous TCP and UDP sockets
  • Asynchronous DNS resolution
  • Asynchronous file and file system operations
  • File system events
  • ANSI escape code controlled TTY
  • IPC with socket sharing, using Unix domain sockets or named pipes (Windows)
  • Child processes
  • Thread pool
  • Signal handling
  • High resolution clock
  • Threading and synchronization primitives

Supported Platforms

  • Microsoft Windows operating systems since Windows XP SP2. It can be built with either Visual Studio or MinGW. Consider using Visual Studio Express 2010 or later if you do not have a full Visual Studio license.

  • Linux using the GCC toolchain.

  • OS X using the GCC or XCode toolchain.

  • Solaris 121 and later using GCC toolchain.

  • AIX 6 and later using GCC toolchain (see notes).

官方 Docs

書籍

《 An Introduction to libuv》英文版
pdf

《An Introduction to libuv》中文翻譯,在線地址,還有github地址
uvbook 中文翻譯

學習這個庫,最重要的是 看源碼 + 練習
用example 進入最好。非常快!!

Tips:

代碼跳轉,查看定義問題

在libev,libuv,libevent的源代碼, 或者復雜點的.h/.c文件中,
想查看 宏定義、自定義類型、struct 里面的內容, 如果寫代碼找不到這些內容,會坑死人。

下面有幾款推薦IDE

差評:

  • sourceInsight 導入時,會提示header太復雜,無法解析,所以無法跳轉 宏定義。(只能跳轉函數)

好評:(優先級從高到低)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM