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

4-callback.js нерабочая очередь колбеков #5

Open
mirkadev opened this issue Feb 2, 2021 · 0 comments
Open

Comments

@mirkadev
Copy link

mirkadev commented Feb 2, 2021

В примере 4-callback.js используется очередь для вызова колбеков, однако каждый экземпляр семафора имеет свою очередь, а не общую, из-за чего потоки, которые не смогут сразу войти в критическую секцию, никогда не исполнят свой код.

class CountingSemaphore {
  constructor(shared, offset = 0, initial) {
    this.counter = new Int32Array(shared, offset, 1);
    if (typeof initial === 'number') {
      this.counter[0] = initial;
    }
    this.queue = [];
  }
}
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

No branches or pull requests

2 participants