Esempio n. 1
0
        /// <summary>
        /// Here we spawn off the thread on ourselves.
        /// </summary>
        public virtual ThreadClass SpawnThread()
        {
            var thread = new ThreadClass(this.Run);

            thread.Start();
            return(thread);
        }
Esempio n. 2
0
 public virtual void Init(IndexReader reader)
 {
     this.Reader = reader;
     TimeElapsed = 0;
     t           = new ThreadClass(new System.Threading.ThreadStart(this.Run));
     t.Start();
 }
Esempio n. 3
0
        /// <summary>
        /// Simple constructor that initializes the data structures for keeping track of the state of each slave.
        /// The constructor receives two parameters: a boolean flag indicating whether the system should display
        /// information that is useful for debugging, and the maximum load per slave (the maximum number of jobs
        /// that a slave can be entrusted with at each time).
        /// </summary>
        public SlaveMonitor(IEvolutionState state, bool showDebugInfo, IMasterProblem problemPrototype)
        {
            ShowDebugInfo    = showDebugInfo;
            State            = state;
            ProblemPrototype = problemPrototype;

            var port = state.Parameters.GetInt(new Parameter(P_EVALMASTERPORT), null);

            MaxJobsPerSlave = state.Parameters.GetInt(new Parameter(P_MAXIMUMNUMBEROFCONCURRENTJOBSPERSLAVE), null);

            UseCompression = state.Parameters.GetBoolean(new Parameter(P_EVALCOMPRESSION), null, false);

            try
            {
                var tempTcpListener = new TcpListener(Dns.GetHostEntry(Dns.GetHostName()).AddressList[0], port);
                tempTcpListener.Start();
                ServSock = tempTcpListener;
            }
            catch (IOException e)
            {
                state.Output.Fatal("Unable to bind to port " + port + ": " + e);
            }

            RandomSeed = (int)DateTimeHelper.CurrentTimeMilliseconds;

            // spawn the thread
            Thread = new ThreadClass(new AnonymousClassRunnable(state, this, problemPrototype).Run);
            Thread.Start();
        }
Esempio n. 4
0
        internal System.Collections.ArrayList coords = null; // list of subgroup coordinators to be contacted

        public virtual void start(System.Collections.ArrayList coords)
        {
            if (t == null)
            {
                this.coords    = coords;
                t              = new ThreadClass(new System.Threading.ThreadStart(this.Run), "MergeTask thread");
                t.IsBackground = true;
                t.Start();
            }
        }
        /// <summary> Sets up the FilterManager singleton.</summary>
        protected internal FilterManager()
        {
            cache          = new HashMap <int, FilterItem>();
            cacheCleanSize = DEFAULT_CACHE_CLEAN_SIZE;             // Let the cache get to 100 items
            cleanSleepTime = DEFAULT_CACHE_SLEEP_TIME;             // 10 minutes between cleanings

            internalFilterCleaner = new FilterCleaner(this);
            ThreadClass fcThread = new ThreadClass(new System.Threading.ThreadStart(internalFilterCleaner.Run));

            // setto be a Daemon so it doesn't have to be stopped
            fcThread.IsBackground = true;
            fcThread.Start();
        }
Esempio n. 6
0
 private void start_button(object sender, EventArgs e)
 {
     info.Clear();
     listener.Start();
     socket     = listener.AcceptSocket();
     info.Text += "start lestinng\n";
     if (socket.Connected)
     {
         info.Text += "new connect";
         ns         = new NetworkStream(socket);
         ae         = new ASCIIEncoding();
         //Создаем новый экземпляр класса ThreadClass
         ThreadClass threadClass = new ThreadClass();
         //Создаем новый поток
         Thread thread = threadClass.Start(ns, fileName, fileCount, this);
     }
 }
Esempio n. 7
0
 public virtual void start()
 {
     if (Enclosing_Instance.conns_NIC_1.Count == 0)
     {
         return;
     }
     if (t != null && !t.IsAlive)
     {
         t = null;
     }
     if (t == null)
     {
         //RKU 7.4.2003, put in threadgroup
         t = new ThreadClass(new System.Threading.ThreadStart(this.Run), "ConnectionTable.ReaperThread");
         t.IsBackground = true; // will allow us to terminate if all remaining threads are daemons
         t.Start();
     }
 }
Esempio n. 8
0
 internal string[] Next()
 {
     if (t == null)
     {
         threadDone = false;
         t          = new ThreadClass(Run);
         t.SetDaemon(true);
         t.Start();
     }
     string[] result;
     lock (this)
     {
         while (tuple == null && nmde == null && !threadDone && !stopped)
         {
             //try
             //{
             Monitor.Wait(this);
             //}
             //catch (ThreadInterruptedException ie)
             //{
             //    throw new ThreadInterruptedException(ie.ToString(), ie);
             //}
         }
         if (tuple != null)
         {
             result = tuple;
             tuple  = null;
             Monitor.Pulse(this);// notify();
             return(result);
         }
         if (nmde != null)
         {
             // Set to null so we will re-start thread in case
             // we are re-used:
             t = null;
             throw nmde;
         }
         // The thread has exited yet did not hit end of
         // data, so this means it hit an exception.  We
         // throw NoMorDataException here to force
         // benchmark to stop the current alg:
         throw new NoMoreDataException();
     }
 }
        protected virtual void Start(int numNodes, double runTimeSec, int maxSearcherAgeSeconds)
        {
            endTimeNanos = Time.NanoTime() + (long)(runTimeSec * 1000000000);
            this.maxSearcherAgeSeconds = maxSearcherAgeSeconds;

            m_nodes = new NodeState[numNodes];
            for (int nodeID = 0; nodeID < numNodes; nodeID++)
            {
                m_nodes[nodeID] = new NodeState(this, Random, nodeID, numNodes);
            }

            long[] nodeVersions = new long[m_nodes.Length];
            for (int nodeID = 0; nodeID < numNodes; nodeID++)
            {
                IndexSearcher s = m_nodes[nodeID].Mgr.Acquire();
                try
                {
                    nodeVersions[nodeID] = m_nodes[nodeID].Searchers.Record(s);
                }
                finally
                {
                    m_nodes[nodeID].Mgr.Release(s);
                }
            }

            for (int nodeID = 0; nodeID < numNodes; nodeID++)
            {
                IndexSearcher s = m_nodes[nodeID].Mgr.Acquire();
                Debug.Assert(nodeVersions[nodeID] == m_nodes[nodeID].Searchers.Record(s));
                Debug.Assert(s != null);
                try
                {
                    BroadcastNodeReopen(nodeID, nodeVersions[nodeID], s);
                }
                finally
                {
                    m_nodes[nodeID].Mgr.Release(s);
                }
            }

            changeIndicesThread = new ChangeIndices(this);
            changeIndicesThread.Start();
        }
Esempio n. 10
0
 internal bool start()
 {
     try
     {
         createSockets();
         if (mcast_receiver == null)
         {
             mcast_receiver = new ThreadClass(new System.Threading.ThreadStart(this.Run), "MPingReceiver thread");
             mcast_receiver.IsBackground = true;
             mcast_receiver.Start();
         }
     }
     catch (Exception e)
     {
         enclosingInstance.Stack.NCacheLog.Error("MPingReceiver.start()", e.ToString());
         return(false);
     }
     return(true);
 }
Esempio n. 11
0
        protected internal virtual void Start(int numNodes, double runTimeSec, int maxSearcherAgeSeconds)
        {
            EndTime = DateTime.UtcNow.AddSeconds(runTimeSec);
            this.MaxSearcherAgeSeconds = maxSearcherAgeSeconds;

            Nodes = new NodeState[numNodes];
            for (int nodeID = 0; nodeID < numNodes; nodeID++)
            {
                Nodes[nodeID] = new NodeState(this, Random(), nodeID, numNodes);
            }

            long[] nodeVersions = new long[Nodes.Length];
            for (int nodeID = 0; nodeID < numNodes; nodeID++)
            {
                IndexSearcher s = Nodes[nodeID].Mgr.Acquire();
                try
                {
                    nodeVersions[nodeID] = Nodes[nodeID].Searchers.Record(s);
                }
                finally
                {
                    Nodes[nodeID].Mgr.Release(s);
                }
            }

            for (int nodeID = 0; nodeID < numNodes; nodeID++)
            {
                IndexSearcher s = Nodes[nodeID].Mgr.Acquire();
                Debug.Assert(nodeVersions[nodeID] == Nodes[nodeID].Searchers.Record(s));
                Debug.Assert(s != null);
                try
                {
                    BroadcastNodeReopen(nodeID, nodeVersions[nodeID], s);
                }
                finally
                {
                    Nodes[nodeID].Mgr.Release(s);
                }
            }

            ChangeIndicesThread = new ChangeIndices(this);
            ChangeIndicesThread.Start();
        }
Esempio n. 12
0
        public static void Main()
        {
            String fileName = "D:\\text.txt";
            int fileCount = 0;

            try
            {
                // Application.EnableVisualStyles();
                //  Application.SetCompatibleTextRenderingDefault(false);
                //  Form1 f = new Form1();
                //  Application.Run(f);
                TcpListener listener = new TcpListener(IPAddress.Any, 2200); //Создание объекта класса Socket 
                Socket socket = null;
                //Создание объекта класса NetworkStream 
                NetworkStream ns = null;
                //Создание объекта класса кодировки ASCIIEncoding 
                ASCIIEncoding ae = null;
                while (true)
                {
                    listener.Start();
                    socket = listener.AcceptSocket();

                    if (socket.Connected)
                    {
                        ns = new NetworkStream(socket);
                        Console.WriteLine("new connect");
                        ae = new ASCIIEncoding();
                        ThreadClass threadClass = new ThreadClass();
                        Thread thread = threadClass.Start(ns, fileName, fileCount);
                    }
                }
            }
            catch
            {

            }

        }
        public virtual void TestIntermediateClose()
        {
            Directory dir = NewDirectory();
            // Test can deadlock if we use SMS:
            IConcurrentMergeScheduler scheduler;

#if !FEATURE_CONCURRENTMERGESCHEDULER
            scheduler = new TaskMergeScheduler();
#else
            scheduler = new ConcurrentMergeScheduler();
#endif
            IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMergeScheduler(scheduler));
            writer.AddDocument(new Document());
            writer.Commit();
            CountdownEvent awaitEnterWarm = new CountdownEvent(1);
            CountdownEvent awaitClose     = new CountdownEvent(1);
            AtomicBoolean  triedReopen    = new AtomicBoolean(false);
            //TaskScheduler es = Random().NextBoolean() ? null : Executors.newCachedThreadPool(new NamedThreadFactory("testIntermediateClose"));
            TaskScheduler   es              = Random().NextBoolean() ? null : TaskScheduler.Default;
            SearcherFactory factory         = new SearcherFactoryAnonymousInnerClassHelper2(this, awaitEnterWarm, awaitClose, triedReopen, es);
            SearcherManager searcherManager = Random().NextBoolean() ? new SearcherManager(dir, factory) : new SearcherManager(writer, Random().NextBoolean(), factory);
            if (VERBOSE)
            {
                Console.WriteLine("sm created");
            }
            IndexSearcher searcher = searcherManager.Acquire();
            try
            {
                assertEquals(1, searcher.IndexReader.NumDocs);
            }
            finally
            {
                searcherManager.Release(searcher);
            }
            writer.AddDocument(new Document());
            writer.Commit();
            AtomicBoolean success = new AtomicBoolean(false);
            Exception[]   exc     = new Exception[1];
            ThreadClass   thread  = new ThreadClass(() => new RunnableAnonymousInnerClassHelper(this, triedReopen, searcherManager, success, exc).Run());
            thread.Start();
            if (VERBOSE)
            {
                Console.WriteLine("THREAD started");
            }
            awaitEnterWarm.Wait();
            if (VERBOSE)
            {
                Console.WriteLine("NOW call close");
            }
            searcherManager.Dispose();
            awaitClose.Signal();
            thread.Join();
            try
            {
                searcherManager.Acquire();
                fail("already closed");
            }
#pragma warning disable 168
            catch (ObjectDisposedException ex)
#pragma warning restore 168
            {
                // expected
            }
            assertFalse(success.Get());
            assertTrue(triedReopen.Get());
            assertNull("" + exc[0], exc[0]);
            writer.Dispose();
            dir.Dispose();
            //if (es != null)
            //{
            //    es.shutdown();
            //    es.awaitTermination(1, TimeUnit.SECONDS);
            //}
        }
Esempio n. 14
0
 public virtual void start()
 {
     if (Enclosing_Instance.conns_NIC_1.Count == 0)
         return;
     if (t != null && !t.IsAlive)
         t = null;
     if (t == null)
     {
         //RKU 7.4.2003, put in threadgroup
         t = new ThreadClass(new System.Threading.ThreadStart(this.Run), "ConnectionTable.ReaperThread");
         t.IsBackground = true; // will allow us to terminate if all remaining threads are daemons
         t.Start();
     }
 }
Esempio n. 15
0
            internal virtual void init()
            {
                if (NCacheLog.IsInfoEnabled) NCacheLog.Info("connection was created to " + peer_addr);
                if (handler == null)
                {

                    // Roland Kurmann 4/7/2003, put in thread_group
                    handler = new ThreadClass(new System.Threading.ThreadStart(this.Run), "ConnectionTable.Connection.HandlerThread");
                    handler.IsBackground = true;
                    handler.Start();
                }

               
            }