Ejemplo n.º 1
0
        public static void ClearAll()
        {
            // TODO: Add SynchronizedHashtable.Clear method.

#if WP7
            // Cannot access Environment.ProcessorCount in phone app. (Security issue).
            _data = new SynchronizedHashtable <int, ProfilerDataCollection>(8);
#else
            _data = new SynchronizedHashtable <int, ProfilerDataCollection>(Environment.ProcessorCount * 4);
#endif
        }
Ejemplo n.º 2
0
        public SubmissionJob(string name, SynchronizedHashtable processingSubmissionIds)
        {
            this.Name = name;

            this.logger = LogManager.GetLogger(name);
            this.logger.Info("SubmissionJob initializing...");

            this.stopping = false;
            this.processingSubmissionIds = processingSubmissionIds;

            this.logger.Info("SubmissionJob initialized.");
        }
Ejemplo n.º 3
0
    /// <summary>
    /// Initializes a new instance of the <see cref="ResourcePool{T}"/> class with the given
    /// un-/initialize methods.
    /// </summary>
    /// <param name="create">
    /// The function that creates a new item of type <typeparamref name="T"/>.
    /// </param>
    /// <param name="initialize">
    /// The method that is executed on an item when it is obtained from the pool - can be
    /// <see langword="null"/>.
    /// </param>
    /// <param name="uninitialize">
    /// The method that is executed on an item when it is recycled - can be <see langword="null"/>.
    /// </param>
    /// <exception cref="ArgumentNullException">
    /// <paramref name="create"/> is <see langword="null"/>.
    /// </exception>
    public ResourcePool(Func<T> create, Action<T> initialize, Action<T> uninitialize)
    {
      if (create == null)
        throw new ArgumentNullException("create");

      _create = create;
      _initialize = initialize;
      _uninitialize = uninitialize;

      _queues = new SynchronizedHashtable<int, WorkStealingQueue<T>>(Environment.ProcessorCount * 4);

      Register(this);
    }
        public BattlesSimulatorJob(string name, SynchronizedHashtable processingBattleIds)
        {
            this.Name = name;

            this.logger = LogManager.GetLogger(name);
            this.logger.Info("BattlesSimulatorJob initializing...");

            this.stopping = false;
            this.processingBattleIds = processingBattleIds;

            this.gamesSimulator = new GamesSimulator.GamesSimulator();

            this.logger.Info("BattlesSimulatorJob initialized.");
        }
Ejemplo n.º 5
0
 public ThreadPoolEx()
 {
     this._threadPoolStartInfo   = new ThreadPoolStartInfo();
     this._workItemsQueue        = new WorkItemsQueue();
     this._workerThreads         = new SynchronizedHashtable();
     this._inUseWorkerThreads    = 0;
     this._isIdleWaitHandle      = new ManualResetEvent(true);
     this._shuttingDownEvent     = new ManualResetEvent(false);
     this._shutdown              = false;
     this._threadCounter         = 0;
     this._isDisposed            = false;
     this._workItemsProcessed    = 0L;
     this._currentWorkItemsCount = 0;
     this._name = "ThreadPoolEx";
     this.Initialize();
 }
Ejemplo n.º 6
0
        public void Test1()
        {
            _stop = false;
            _c    = new SynchronizedHashtable <int, object>(10);
            var t1 = Parallel.Start(Query1);
            var t2 = Parallel.Start(Query2);
            var t3 = Parallel.Start(Add);
            var t4 = Parallel.Start(Remove);

            Thread.Sleep(2000);

            _stop = true;
            t1.Wait();
            t2.Wait();
            t3.Wait();
            t4.Wait();
        }
        public void Test1()
        {
            _stop = false;
              _c = new SynchronizedHashtable<int, object>(10);
              var t1 = Parallel.Start(Query1);
              var t2 = Parallel.Start(Query2);
              var t3 = Parallel.Start(Add);
              var t4 = Parallel.Start(Remove);

              Thread.Sleep(2000);

              _stop = true;
              t1.Wait();
              t2.Wait();
              t3.Wait();
              t4.Wait();
        }
        public LocalWorkerService()
        {
            logger = LogManager.GetLogger("LocalWorkerService");
            logger.Info("LocalWorkerService initializing...");

            this.threads = new List <Thread>();
            this.jobs    = new List <IJob>();
            var processingSubmissionIds = new SynchronizedHashtable();

            for (var i = 1; i <= Settings.ThreadsCount; i++)
            {
                var job    = new SubmissionJob(string.Format("Job №{0}", i), processingSubmissionIds);
                var thread = new Thread(job.Start)
                {
                    Name = string.Format("Thread №{0}", i)
                };
                this.jobs.Add(job);
                this.threads.Add(thread);
            }

            logger.Info("LocalWorkerService initialized.");
        }
Ejemplo n.º 9
0
 public RtmptServer(RtmptEndpoint endpoint)
 {
     _connections = new SynchronizedHashtable();
     _endpoint    = endpoint;
     _rtmpHandler = new RtmpHandler(endpoint);
 }
Ejemplo n.º 10
0
        public static void ClearAll()
        {
            // TODO: Add SynchronizedHashtable.Clear method.

            #if WP7
              // Cannot access Environment.ProcessorCount in phone app. (Security issue).
              _data = new SynchronizedHashtable<int, ProfilerDataCollection>(8);
            #else
              _data = new SynchronizedHashtable<int, ProfilerDataCollection>(Environment.ProcessorCount * 4);
            #endif
        }
Ejemplo n.º 11
0
 private WorkItem()
 {
     _resetEvent = new ManualResetEvent(false);
     _exceptions = new SynchronizedHashtable <int, Exception[]>(1);
     _children   = new List <Task>();
 }