/**
 * Prevents concurrent executions of the menu update cycle.
 * Returns an object with tryAcquire() / release() so the lock can be tested
 * without importing Electron.
 */
function createUpdateGuard() {
  let running = false;

  return {
    tryAcquire() {
      if (running) return false;
      running = true;
      return true;
    },
    release() {
      running = false;
    },
    get isRunning() {
      return running;
    }
  };
}

module.exports = { createUpdateGuard };
