Skip to content

Conversation

@YuraG97
Copy link

@YuraG97 YuraG97 commented Jun 2, 2017

No description provided.

if (this.process.length > 0) {
const fn = this.process.shift();
const item = this.get();
fn(item, () => {
Copy link
Member

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);
Copy link
Member

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) => {
Copy link
Member

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants