Skip to content

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

Description

@mirkadev

В примере 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 = [];
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions