Comments (3)
"This callback will be ran inside a thread managed by libeio. The first step is to extract the baton structure, so we have access to our context. Next we sleep for the value of baton->sleep_for, which is safe to do, because we are in a thread, and not blocking all Javascript execution in the main thread. Then we do the work of incrementing the count, which if this wasn't just a simple example you would want to wrap in a Lock/Mutex."
https://www.cloudkick.com/blog/2010/aug/23/writing-nodejs-native-extensions/
from geoip.
In that example, the sleep was used just to demonstrate that the execution is non-blocking. It seems to have no use in this module. It's delaying the callback execution for no reason (as far as I can see). If I'm running this module in a situation where I need to look up thousands of IP records every second, I can't have it waiting for a whole second before executing the callback every time.
from geoip.
let me make it clear.
The is my first c++ addon for nodejs. So I just followed that tutorial during the whole process of build this package.
Honestly, the async(non-blocking) methods are just for demonstration and very rare situations at this point of time.
Because the databases are cached in the memory in most cases, the concept of non-blocking dose not apply to these cases.
So you should always use synchronous methods (e.g city.lookupSync ), at least in the normal cases.
If this make your confused, this is my fault,I am apologize for that.
--kuno
from geoip.
Related Issues (20)
- installation problema HOT 7
- Bug in the async country lookup method HOT 7
- Build fails on Windows 7 HOT 13
- nan.h error on node v0.10.22 HOT 14
- GeoIP on Ubuntu 13.10 HOT 7
- installation problem HOT 2
- core dump when invalid data file supplied HOT 2
- build fails under node v0.11.13 HOT 2
- Compile for io.js 1.0.4 HOT 2
- nan ~1.8.4 required for io.js 2.x.x compatibility HOT 1
- Synchronous method(the recommended way). why? HOT 1
- Installation on CentOs
- Build failed on io.js v2.3.1 HOT 1
- IP2Location LITE Support HOT 1
- use of static to get the value of info HOT 2
- OS X 10.11 Installation Issues HOT 2
- Doesn't build with nodejs 6.1.0 HOT 3
- Is it possible to use GeoIP2-City.mmdb ?
- Bug report(Mac os X 10.12) HOT 1
- Respect DNT
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geoip.