Exemplo n.º 1
0
        public void removeKey(SelectionKey k)
        {
            lock (keyLock)
            {
                for (int i = 0; i < keys.Length; i++)
                {
                    if (keys[i] == k)
                    {
                        keys[i] = null;
                        keyCount--;
                    }
                }

//				((AbstractSelectionKey)k).invalidate();
            }
        }
Exemplo n.º 2
0
 public override SelectionKey register(Selector sel, Object att)
 {
     lock (regLock)
     {
         SelectionKey k = findKey(sel);
         if (k != null)
         {
             k.attach(att);
         }
         if (k == null)
         {
             // New registration
             lock (keyLock)
             {
                 // sabal continue
                 k = ((AbstractSelector)sel).register(this, att);
                 addKey(k);
             }
         }
         return(k);
     }
 }
Exemplo n.º 3
0
        private void addKey(SelectionKey k)
        {
            Debug.Assert(Monitor.TryEnter(keyLock));

            int i = 0;

            if ((keys != null) && (keyCount < keys.Length))
            {
                // Find empty element of key array
                for (i = 0; i < keys.Length; i++)
                {
                    if (keys[i] == null)
                    {
                        break;
                    }
                }
            }
            else if (keys == null)
            {
                keys = new SelectionKey[3];
            }
            else
            {
                // Grow key array
                int            n  = keys.Length * 2;
                SelectionKey[] ks = new SelectionKey[n];
                for (i = 0; i < keys.Length; i++)
                {
                    ks[i] = keys[i];
                }
                keys = ks;
                i    = keyCount;
            }
            keys[i] = k;
            keyCount++;
        }