libuv

Does the .pipe() perform a memcpy in node.js?

妖精的绣舞 提交于 2019-12-21 04:18:20
问题 This is a conceptual query regarding system level optimisation. My understanding by reading the NodeJS Documentation is that pipes are handy to perform flow control on streams. Background: I have microphone stream coming in and I wanted to avoid an extra copy operation to conserve overall system MIPS. I understand that for audio streams this is not a great deal of MIPS being spent even if there was a memcopy under the hood, but I also have an extension planned to stream in camera frames at

Confusion about node.js internal asynchronous I/O mechanism

吃可爱长大的小学妹 提交于 2019-12-17 21:53:37
问题 I have learned that node.js use libeio internally to perform async file I/O, with thread pool, on *nix platform, am I right? What about async network I/O? Is it done by libev? Is there also a thread pool? If there is thread pool inside, how could it be more efficient than traditional one-thread-per-request model? And is it one thread per I/O request? And what's the mechanism on windows? I know it's done by IOCP, and there's a kernel level thread pool, right? Why linux doesn't have a native

How to do async file io in qt?

末鹿安然 提交于 2019-12-12 08:16:04
问题 I was wondering how to achieve async file io in qt? Is this even achievable in vanilla qt or would someone need to use another library (libuv for example) to achieve something like this? I was looking at QDataStream but even though it is a "stream" it isn't non blocking. I guess one solution would be to make a custom QIODevice that uses libuv internally which can then be used with QDataStream but not sure where to start. Any ideas? Thanks for any help provided. 回答1: I would implement a thread

Does nextTick means next phase in Node.js (Event Loop)?

╄→гoц情女王★ 提交于 2019-12-12 05:44:10
问题 What does process.nextTick exactly mean ? Does nextTick mean, after callback queue pop for one element in the current phase ? Or before moving to the next phase after executing all callbacks in the current phase's queue ? 回答1: This is described in the documentation. nextTick queues callbacks to be invoked at the end of the current tick. The entire queue is emptied before moving to the next tick. Contrast with setImmediate, which queues callbacks to be invoked during the next tick. (Yes, the

libUV编译步骤

若如初见. 提交于 2019-12-11 19:35:20
libUV库下载地址: https://github.com/libuv/libuv https://dist.libuv.org/dist/ 解压之后,进入源文件打开readme.md文件就可以看到编译步骤 别人libUV的blog Build Instructions For GCC there are two build methods: via autotools or via GYP. GYP is a meta-build system which can generate MSVS, Makefile, and XCode backends. It is best used for integration into other projects. To build with autotools: $ sh autogen.sh $ ./configure $ make $ make check $ make install Windows First, Python 2.6 or 2.7 must be installed as it is required by GYP. If python is not in your path, set the environment variable PYTHON to its location. For example:

JavaScript Internals: At what interval does the event loop run?

跟風遠走 提交于 2019-12-11 13:26:40
问题 This is a question about JavaScript internals. Lets say I have 10 async tasks that all take x number of seconds to run. Whilst waiting for a response the script is idle. In the background the JavaScript engine is asking "Is there anything on the task queue". To my understanding this is a loop. Hence, event loop. I know in Node this is implemented with Libuv. I've read this article which explains a little: https://nikhilm.github.io/uvbook/basics.html Do JavaScript engines place any restriction

print libuv threadpool size in node js 8

倖福魔咒の 提交于 2019-12-11 07:27:40
问题 This link purely specifies that libuv provides a thread pool which can be used to run user code and get notified in the loop thread. Its default size is 4, but it can be changed at startup time by setting the UV_THREADPOOL_SIZE environment variable to any value. (the absolute maximum is 128). So, in package.json , I set scripts field as below ( NOTE : I am using Windows 7, Node JS 8.11.3, nodemon, express 4.16), Code snippet from package.json . . . "scripts": { "start": "SET UV_THREADPOOL

Invoking some callback function twice leads to Segmentation fault: Nan

六眼飞鱼酱① 提交于 2019-12-11 03:35:16
问题 I am writing C++ addon using nbind - GitHub link for most thing and Nan - GitHub link for calling callbacks asynchronous. When I invoke callback only once, it works perfect. But When I invoke callback twice it gives Segmentation fault (core dumped) . Couldn't find error using gdb . Here is JS and C++ codes(compiling using node-gyp configure build ): //main.js code var nbind = require('nbind'); var lib = nbind.init().lib; lib.HeaderExample.callJS(function(a) { console.log("result" + a); });

Compiling libuv with libwebsockets

邮差的信 提交于 2019-12-10 18:36:00
问题 I am trying to run the "libwebsockets-test-server" that is installed with the LWS library, but it will not run because "lwsts[31616]: libuv support not compiled in". I have checked that libuv is installed (1.8.0). I also changed the setting for LIBUV in cmake and recompiled the library. LWS_USE_LIBUV = 1 How do I get the project compiled with libuv? I am on Ubuntu 16.04, cross-compiling using arm-linux-gcc. I have successfully compiled programs, loaded them to the embedded board (TS-7800),

how libuv threads in nodejs utilize multi core cpu

梦想的初衷 提交于 2019-12-10 13:54:40
问题 I am not able to find out whether libuv in node.js uses multi core cpus or it runs all of its threads in on single core only using time slicing? As node.js is single threaded but libuv has its own thread pool so does it use all the cores of multi core cpu? 回答1: It does leverage multicores via the threadpool. e.g., on Linux, the underlying pthreads will uses multiple cores for multiple threads. If you run the following code, you will notice 4 (default threadpool size) cores will peg at 100% as