Skip to content
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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

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