Beispiel #1
0
        private IDIDATuple Add(IDIDATuple didatuple, bool fromUnfreeze)
        {
            DIDATuple didaAdd = (DIDATuple)didatuple;

            if ((pending.Count == 0 && isfrozen == false) || fromUnfreeze)
            {
                tupleSpace.Add(didaAdd);
                numOps++;
                size++;
                Console.Write("Client added new tuple : ");
                this.PrintTuple(didaAdd);

                //se tiver algum client a espera deste tuplo
                foreach (KeyValuePair <string, DIDATuple> elem in queuedClients)
                {
                    if (elem.Value.CompareParams(didaAdd))
                    {
                        notifyClient(elem.Key);
                    }
                }

                if (didaAdd.getBroadme())
                {
                    didaAdd.setBroadme(false);
                    this.BroadcastAdd(didaAdd);
                }

                return(didaAdd);
            }
            else
            {
                Console.Write("Client added new tuple inserted to the queue : ");
                this.PrintTuple(didaAdd);

                pending.Enqueue(new KeyValuePair <string, DIDATuple>("add", didaAdd));
                return(null);
            }
        }