function flush() {
  release()

  let task
  while (!semaphore && (task = queue.shift()) !== undefined) {
    exec(task)
  }
}
Releases the current lock. Executes all queued tasks if the scheduler is in the released state.