Loading

Paste #pfcms3rt4

  1. function Door:checkForDeadlock()
  2.   -- In an ideal world, deadlocks should not occur, as they indicate errors in
  3.   -- some logic elsewhere. From a practical point of view, we should check for
  4.   -- deadlocks from time to time and attempt to fix them.
  5.   if self.queue and self.reserved_for then
  6.     -- If the door is reserved for someone, then that person should either be
  7.     -- at the front of the queue, or not in any queues at all.
  8.     for _, action in ipairs(self.reserved_for.action_queue) do
  9.       if action.name == "queue" then
  10.         if action.queue ~= self.queue or self.queue[1] ~= self.reserved_for then
  11.           self.reserved_for = nil
  12.           self:getRoom():tryAdvanceQueue()
  13.         end
  14.         break
  15.       end
  16.     end
  17.   end
  18. end

Comments