-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yurii Havryliuk IT-42 #5
base: master
Are you sure you want to change the base?
Conversation
if (this.process.length > 0) { | ||
const fn = this.process.shift(); | ||
const item = this.get(); | ||
fn(item, () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn(item, () => this.put(item));
this.put(worker); | ||
}); | ||
} else { | ||
this.process.push(func); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better use this to optimize like this
Queue.prototype.use = function(func) {
if (!this.queue.length) return this.process.push(func);
const worker = this.get();
func(worker, () => this.put(worker));
};
api.net.createServer((socket) => { | ||
console.log('Conn: ' + socket.remoteAddress + ':' + socket.remotePort); | ||
const handler = createHandler(socket); | ||
socket.on('error', (err) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just socket.on('error', console.error);
No description provided.