示例#1
0
 public void submit()
 {
     if (!submitted)
     {
         lockTask(true);
         int gameIndex = GameObject.Find("ResourceManager").transform.GetComponent <ResourceManage> ().gameIndex;
         pp = Instantiate(processorPool).GetComponent <ProcessorPool>();
         pp.transform.SetParent(GameObject.Find("Panel Grider").transform);
         pp.loadAnswer(GameObject.Find("ResourceManager").GetComponent <ResourceManage>().getGame(gameIndex));
         taskPool.SetActive(false);
         taskInfo.transform.SetAsFirstSibling();
         standardAnswer.gameObject.SetActive(true);
         submitButton.text = "Try Again";
         submitted         = true;
     }
     else
     {
         Destroy(pp.gameObject);
         taskPool.SetActive(true);
         lockTask(false);
         submitted         = false;
         submitButton.text = "Submit";
         standardAnswer.gameObject.SetActive(false);
     }
 }
 void ReleaseProcessor(EndpointAddressProcessor processor)
 {
     lock (processorPool)
     {
         ProcessorPool pool = processorPool.Target as ProcessorPool;
         if (null == pool)
         {
             pool = new ProcessorPool();
             processorPool.Target = pool;
         }
         pool.Push(processor);
     }
 }
 private void ReleaseProcessor(EndpointAddressProcessor processor)
 {
     lock (this.processorPool)
     {
         ProcessorPool <TFilterData> target = this.processorPool.Target as ProcessorPool <TFilterData>;
         if (target == null)
         {
             target = new ProcessorPool <TFilterData>();
             this.processorPool.Target = target;
         }
         target.Push(processor);
     }
 }
        private EndpointAddressProcessor CreateProcessor(int length)
        {
            EndpointAddressProcessor processor = null;

            lock (this.processorPool)
            {
                ProcessorPool <TFilterData> target = this.processorPool.Target as ProcessorPool <TFilterData>;
                if (target != null)
                {
                    processor = target.Pop();
                }
            }
            if (processor != null)
            {
                processor.Clear(length);
                return(processor);
            }
            return(new EndpointAddressProcessor(length));
        }
        EndpointAddressProcessor CreateProcessor(int length)
        {
            EndpointAddressProcessor p = null;

            lock (processorPool)
            {
                ProcessorPool pool = processorPool.Target as ProcessorPool;
                if (null != pool)
                {
                    p = pool.Pop();
                }
            }

            if (null != p)
            {
                p.Clear(length);
                return(p);
            }

            return(new EndpointAddressProcessor(length));
        }
示例#6
0
        private void OnPICSProductInfo(SteamApps.PICSProductInfoCallback callback, JobID jobID)
        {
            var request = SteamProxy.Instance.IRCRequests.Find(r => r.JobID == jobID);

            if (request != null)
            {
                SteamProxy.Instance.IRCRequests.Remove(request);

                SecondaryPool.QueueWorkItem(SteamProxy.Instance.OnProductInfo, request, callback);

                return;
            }

            foreach (var app in callback.Apps)
            {
                Log.WriteInfo("Steam", "AppID: {0}", app.Key);

                var workaround = app;

                IWorkItemResult mostRecentItem;
                ProcessedApps.TryGetValue(workaround.Key, out mostRecentItem);

                var workerItem = ProcessorPool.QueueWorkItem(delegate
                {
                    if (mostRecentItem != null && !mostRecentItem.IsCompleted)
                    {
                        Log.WriteDebug("Steam", "Waiting for app {0} to finish processing", workaround.Key);

                        SmartThreadPool.WaitAll(new IWaitableResult[] { mostRecentItem });
                    }

                    new AppProcessor(workaround.Key).Process(workaround.Value);
                });

                ProcessedApps.AddOrUpdate(app.Key, workerItem, (key, oldValue) => workerItem);
            }

            foreach (var package in callback.Packages)
            {
                Log.WriteInfo("Steam", "SubID: {0}", package.Key);

                var workaround = package;

                IWorkItemResult mostRecentItem;
                ProcessedSubs.TryGetValue(workaround.Key, out mostRecentItem);

                var workerItem = ProcessorPool.QueueWorkItem(delegate
                {
                    if (mostRecentItem != null && !mostRecentItem.IsCompleted)
                    {
                        Log.WriteDebug("Steam", "Waiting for package {0} to finish processing", workaround.Key);

                        SmartThreadPool.WaitAll(new IWaitableResult[] { mostRecentItem });
                    }

                    new SubProcessor(workaround.Key).Process(workaround.Value);
                });

                ProcessedSubs.AddOrUpdate(package.Key, workerItem, (key, oldValue) => workerItem);
            }

            foreach (uint app in callback.UnknownApps)
            {
                Log.WriteInfo("Steam", "Unknown AppID: {0}", app);

                uint workaround = app;

                IWorkItemResult mostRecentItem;
                ProcessedApps.TryGetValue(workaround, out mostRecentItem);

                var workerItem = ProcessorPool.QueueWorkItem(delegate
                {
                    if (mostRecentItem != null && !mostRecentItem.IsCompleted)
                    {
                        Log.WriteDebug("Steam", "Waiting for app {0} to finish processing (unknown)", workaround);

                        SmartThreadPool.WaitAll(new IWaitableResult[] { mostRecentItem });
                    }

                    new AppProcessor(workaround).ProcessUnknown();
                });

                ProcessedApps.AddOrUpdate(app, workerItem, (key, oldValue) => workerItem);
            }

            foreach (uint package in callback.UnknownPackages)
            {
                Log.WriteInfo("Steam", "Unknown SubID: {0}", package);

                uint workaround = package;

                IWorkItemResult mostRecentItem;
                ProcessedSubs.TryGetValue(workaround, out mostRecentItem);

                var workerItem = ProcessorPool.QueueWorkItem(delegate
                {
                    if (mostRecentItem != null && !mostRecentItem.IsCompleted)
                    {
                        Log.WriteDebug("Steam", "Waiting for package {0} to finish processing (unknown)", workaround);

                        SmartThreadPool.WaitAll(new IWaitableResult[] { mostRecentItem });
                    }

                    new SubProcessor(workaround).ProcessUnknown();
                });

                ProcessedSubs.AddOrUpdate(package, workerItem, (key, oldValue) => workerItem);
            }
        }