public void Add(TKey key, TValue value)
 {
     using (ReadLock readLock = new ReadLock(this.readerWriterLockSlim_0))
     {
         this.dict.Add(key, value);
     }
 }
 public void Clear()
 {
     using (ReadLock readLock = new ReadLock(this.readerWriterLockSlim_0))
     {
         this.dict.Clear();
     }
 }
Ejemplo n.º 3
0
        public void Update(Controllers.BaseControllers controllers, GameObject ownerEnt, double dt)
        {
            using (UpgradeableReadLock.CreateLock(m_componentsAddQueueLock))
            {
                foreach (var comp in m_componentsAddQueue)
                {
                    AddComponent(comp);
                }

                using (WriteLock.CreateLock(m_componentsAddQueueLock))
                {
                    m_componentsAddQueue.Clear();
                }
            }

            using (WriteLock.CreateLock(m_componentsRemoveQueueLock))
            {
                foreach (var comp in m_componentsRemoveQueue)
                {
                    m_componentsSorted.Remove(comp);
                }

                m_componentsRemoveQueue.Clear();
            }

            using (ReadLock.CreateLock(m_componentsSortedLock))
            {
                foreach (var component in m_componentsSorted)
                {
                    component.Value.Tick(controllers, ownerEnt, dt);
                }
            }
        }
Ejemplo n.º 4
0
        protected async override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();

            if (!CreatedByTinyMvvm && BindingContext is ViewModelBase viewModel)
            {
                SetupUIAction(viewModel);
                try
                {
                    if (TinyId != null)
                    {
                        var shellNavigationHelper = (ShellNavigationHelper)NavigationHelper.Current;

                        var parameters = shellNavigationHelper.GetQueryParameters(TinyId);
                        viewModel.NavigationParameter = parameters;
                    }

                    await ReadLock.WaitAsync();

                    await viewModel.Initialize();
                }
                finally
                {
                    ReadLock.Release();
                }
            }
        }
Ejemplo n.º 5
0
 public bool IsContain(int ID)
 {
     using (ReadLock.TryEnter(this.readerWriterLockSlim, 1000))
     {
         return(Clients.ContainsKey(ID));
     }
 }
Ejemplo n.º 6
0
 public bool IsContain(string name)
 {
     using (ReadLock.TryEnter(this.readWriteLock, 1000))
     {
         return(Clients.Exists(n => n.CharacterName.Equals(name)));
     }
 }
Ejemplo n.º 7
0
 public UnityClient TryGetByName(string name)
 {
     using (ReadLock.TryEnter(this.readWriteLock, 1000))
     {
         return(Clients.Find(n => n.CharacterName.Equals(name)));
     }
 }
Ejemplo n.º 8
0
 public void AddClient(UnityClient client)
 {
     using (ReadLock.TryEnter(this.readWriteLock, 1000))
     {
         Clients.Add(client);
     }
 }
Ejemplo n.º 9
0
        protected virtual void Dispose(bool disposing)
        {
            if (_Disposed)
            {
                return;
            }

            if (disposing)
            {
                if (_SslStream != null)
                {
                    _SslStream.Close();
                }

                if (_NetworkStream != null)
                {
                    _NetworkStream.Close();
                }

                if (_TcpClient != null)
                {
                    _TcpClient.Close();
                }
            }

            ReadLock.Dispose();
            WriteLock.Dispose();

            _Disposed = true;
        }
Ejemplo n.º 10
0
 public void RemoveClient(UnityClient client)
 {
     using (ReadLock.TryEnter(this.readWriteLock, 1000))
     {
         Clients.Remove(client);
     }
 }
Ejemplo n.º 11
0
 public void TestReadLockTimeout()
 {
     using (ILockStrategy l = LockFactory.Create())
         using (new ThreadedWriter(l))
             using (ReadLock r = new ReadLock(l, 0))
                 Assert.IsFalse(r.HasReadLock);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// The try get.
 /// </summary>
 /// <param name="name">
 /// The world name.
 /// </param>
 /// <param name="world">
 /// The world.
 /// </param>
 /// <returns>
 /// true if found.
 /// </returns>
 public bool TryGet(string name, out MmoWorld world)
 {
     using (ReadLock.TryEnter(this.readWriteLock, Settings.MaxLockWaitTimeMilliseconds))
     {
         return(this.dict.TryGetValue(name, out world));
     }
 }
Ejemplo n.º 13
0
 public bool Contains(int actorId)
 {
     using (ReadLock.Enter(_actorsLock))
     {
         return(_actors.ContainsKey(actorId));
     }
 }
 public virtual void Add(KeyValuePair <TKey, TValue> item)
 {
     using (ReadLock readLock = new ReadLock(this.readerWriterLockSlim_0))
     {
         this.dict.Add(item);
     }
 }
Ejemplo n.º 15
0
 public bool TryGetItem(string itemId, out Item item)
 {
     using (ReadLock.TryEnter(this.readerWriterLock, this.maxLockMilliseconds))
     {
         return(this.items.TryGetValue(itemId, out item));
     }
 }
Ejemplo n.º 16
0
 public void TestYouCanDisposeReadLock()
 {
     using (ILockStrategy l = LockFactory.Create())
         using (IDisposable r = ReadLock.Acquire(l, 0))
         {
             r.Dispose();//since the using statement has the same boxed pointer to r, we are allowed to dispose
         }
 }
Ejemplo n.º 17
0
 public bool ContainsComponents <TComponent1, TComponent2>()
     where TComponent1 : IComponent where TComponent2 : IComponent
 {
     using (ReadLock.Enter(_lock))
     {
         return(_components.ContainsComponents <TComponent1, TComponent2>());
     }
 }
Ejemplo n.º 18
0
 public bool TryGetPeer(HttpContext context, string connectionId, out PhotonHttpPeer peer)
 {
     using (ReadLock.Enter(this.readerWriterLock))
     {
         peer = context.Cache.Get(connectionId) as PhotonHttpPeer;
     }
     return(peer != null);
 }
Ejemplo n.º 19
0
	    public static IDisposable Reader(bool canReadUnfrozen = false)
	    {
            IDisposable l = new ReadLock(ConfigurationLock);
            if (canReadUnfrozen || _isFrozen) return l;

            l.Dispose();
            throw new InvalidOperationException("Resolution is not frozen, it is not yet possible to get values from it.");
	    }
 public void Execute()
 {
     using(var myLock = new ReadLock()) //Noncompliant
     {
         int a = 4;
         int fun= somefun();
     }  
         
 }
Ejemplo n.º 21
0
 public void AddMessage(string message)
 {
     using (ReadLock.TryEnter(this.readWriteLock, 1000))
     {
         Messages.Add(message);
         if (Messages.Count > MAX_BUFFERED_MESSAGES)
             Messages = Messages.Skip(Messages.Count - MAX_RECENT_MESSAGES).ToList();
     }
 }
Ejemplo n.º 22
0
 public void TestIdiotReaderUsesDispose()
 {
     using (ILockStrategy l = LockFactory.Create())
         using (ReadLock r = new ReadLock(l, 0))
         {
             Assert.IsTrue(r.HasReadLock);
             ((IDisposable)r).Dispose(); //You cannot do this, the using statement has a 'copy' of ReadLock, don't call dispose.
         }
 }
Ejemplo n.º 23
0
 public void Reset()
 {
     using (var wl = new ReadLock(this.StreamsLock))
     {
         foreach (FifoStream audiostream in this.streams)
         {
             audiostream.Clear();
         }
     }
 }
Ejemplo n.º 24
0
 public void OpenWrite()
 {
     using (var wl = new ReadLock(this.StreamsLock))
     {
         foreach (FifoStream audiostream in this.streams)
         {
             audiostream.OpenWrite();
         }
     }
 }
        public bool Remove(KeyValuePair <TKey, TValue> item)
        {
            bool flag;

            using (ReadLock readLock = new ReadLock(this.readerWriterLockSlim_0))
            {
                flag = this.dict.Remove(item);
            }
            return(flag);
        }
        public bool Remove(TKey key)
        {
            bool flag;

            using (ReadLock readLock = new ReadLock(this.readerWriterLockSlim_0))
            {
                flag = this.dict.Remove(key);
            }
            return(flag);
        }
 private void CompliantPositiveCheckCoversComplete()
 {
     using (var domainLock = new ReadLock(MarkerInterpretation, SeismicInterpretation))
     {
         if (domainLock.LockApplied)
         {
             int a = 10;
         }
     }
 }
Ejemplo n.º 28
0
 public void SetSetAudio(FifoStream audiostream, bool muted, float volume)
 {
     using (var rl = new ReadLock(this.StreamsLock))
     {
         int ind = streams.IndexOf(audiostream);
         if (ind != -1)
         {
             this.streaminfo[ind].Set(muted, volume);
         }
     }
 }
 public void imethod_0(TKey gparam_0, TValue gparam_1)
 {
     using (ReadLock readLock = new ReadLock(this.readerWriterLockSlim_0))
     {
         if (this.dict.ContainsKey(gparam_0))
         {
             this.dict.Remove(gparam_0);
         }
         this.dict.Add(gparam_0, gparam_1);
     }
 }
Ejemplo n.º 30
0
        public bool TryGet(int actorId, out Actor actor)
        {
            bool result;

            using (ReadLock.Enter(_actorsLock))
            {
                result = _actors.TryGetValue(actorId, out actor);
            }

            return(result);
        }
Ejemplo n.º 31
0
 public float[] GetAudioLevels(FifoStream audiostream)
 {
     using (var wl = new ReadLock(this.StreamsLock))
     {
         int ind = streams.IndexOf(audiostream);
         if (ind == -1)
         {
             return(new float[0]);
         }
         return(this.streaminfo[ind].audiolevel);
     }
 }
Ejemplo n.º 32
0
        public static IDisposable Reader(bool canReadUnfrozen = false)
        {
            IDisposable l = new ReadLock(ConfigurationLock);

            if (canReadUnfrozen || _isFrozen)
            {
                return(l);
            }

            l.Dispose();
            throw new InvalidOperationException("Resolution is not frozen, it is not yet possible to get values from it.");
        }
Ejemplo n.º 33
0
 public void CloseWrite()
 {
     using (var wl = new ReadLock(this.StreamsLock))
     {
         for (int nit = 0; nit < this.streams.Count; nit++)
         {
             if (this.streaminfo[nit].running)
             {
                 this.streams[nit].CloseWrite();
             }
         }
     }
 }
 private void CompliantPositiveCheckCoversComplete()
 {
     for (int i = 0; ;)
     {
         using (var domainLock = new ReadLock(MarkerInterpretation, SeismicInterpretation))
         {
             if (!domainLock.LockApplied)
             {
                 continue;
             }
         }
     }
 }