/// <summary> /// Register a new entrance / exit of this area. /// </summary> /// <param name="from">The from part of the connecting edge.</param> /// <param name="to">The to part of the connecting edge.</param> /// <param name="entry">Defines whether the connection is an entrance or an exit.</param> /// <param name="barrier">Defines whether the connection is blocked as soon as the limit of requests is reached.</param> /// <returns>The guard protecting the corresponding connection.</returns> public QueueGuard RegisterGuard(Waypoint from, Waypoint to, bool entry, bool barrier) { QueueGuard guard = new QueueGuard(from, to, entry, barrier, this); _guards.Add(guard); from.RegisterGuard(guard); return(guard); }
/// <summary> /// Registers a guard for a connection to another waypoint. /// </summary> /// <param name="guard">The guard monitoring the connection.</param> internal void RegisterGuard(QueueGuard guard) { if (!_guards.ContainsKey(guard.To)) { _guards[guard.To] = new List <QueueGuard>(); } _guards[guard.To].Add(guard); }
/// <summary> /// Unregisters the guard from this waypoint. /// </summary> /// <param name="guard">The guard to unregister.</param> internal void UnregisterGuard(QueueGuard guard) { if (_guards.ContainsKey(guard.To)) { _guards[guard.To].Remove(guard); if (_guards[guard.To].Count == 0) { _guards.Remove(guard.To); } } }
/// <summary> /// Unregisters the guard from this semaphore. /// </summary> /// <param name="guard">The guard to remove.</param> public void UnregisterGuard(QueueGuard guard) { _guards.Remove(guard); guard.From.UnregisterGuard(guard); }