Ejemplo n.º 1
0
        public void Free()
        {
            lock (globalLock) {
                if (--poolUsers > 0)
                {
                    return;
                }

                lock (workItems) {
                    stopped = true;
                    threadDone.Set();
                    workItems.Clear();
                    foreach (Thread t in runningThreads)
#if !TARGET_JVM
                    { t.Abort(); }
#else
                    { t.Interrupt(); }
#endif
                    runningThreads.Clear();
                }
                if (this == sharedPool)
                {
                    sharedPool = null;
                }
            }
        }
		public static RemotingThreadPool GetSharedPool ()
		{
			lock (globalLock) {
				if (sharedPool == null)
					sharedPool = new RemotingThreadPool ();
				sharedPool.poolUsers++;
			}
			return sharedPool;
		}
Ejemplo n.º 3
0
 public static RemotingThreadPool GetSharedPool()
 {
     lock (globalLock) {
         if (sharedPool == null)
         {
             sharedPool = new RemotingThreadPool();
         }
         sharedPool.poolUsers++;
     }
     return(sharedPool);
 }
Ejemplo n.º 4
0
		public void Free ()
		{
			lock (globalLock) {
				if (--poolUsers > 0)
					return;
				
				lock (workItems) {
					stopped = true;
					threadDone.Set ();
					workItems.Clear ();
					foreach (Thread t in runningThreads)
						t.Abort ();
					runningThreads.Clear ();
				}
				if (this == sharedPool)
					sharedPool = null;
			}
		}
		public void Free ()
		{
			lock (globalLock) {
				if (--poolUsers > 0)
					return;
				
				lock (workItems) {
					stopped = true;
					threadDone.Set ();
					workItems.Clear ();
					foreach (Thread t in runningThreads)
#if !TARGET_JVM
						t.Abort ();
#else
						t.Interrupt();
#endif
					runningThreads.Clear ();
				}
				if (this == sharedPool)
					sharedPool = null;
			}
		}
Ejemplo n.º 6
0
		public void StartListening (object data)
		{
#if TARGET_JVM
			stopped = false;
#endif 
			listener = new TcpListener (bindAddress, port);
			if (server_thread == null) 
			{
				threadPool = RemotingThreadPool.GetSharedPool ();
				listener.Start ();
				
				if (port == 0)
					port = ((IPEndPoint)listener.LocalEndpoint).Port;

				string[] uris = new String [1];
				uris = new String [1];
				uris [0] = GetChannelUri ();
				channel_data.ChannelUris = uris;

				server_thread = new Thread (new ThreadStart (WaitForConnections));
				server_thread.IsBackground = true;
				server_thread.Start ();
			}
		}
		public void StartListening (Object data)
		{
			if (_bListening) return;
			
			threadPool = RemotingThreadPool.GetSharedPool ();
			
			_tcpListener = new TcpListener (_bindToAddr, _port);
			_tcpListener.Start();

			if (_port == 0) {
				_port = ((IPEndPoint)_tcpListener.LocalEndpoint).Port;
				String[] uris = { this.GetChannelUri() };
				_channelData.ChannelUris = uris;
			}
				
			if(_listenerThread == null)
			{
				ThreadStart t = new ThreadStart(this.Listen);
				_listenerThread = new Thread(t);
				_listenerThread.IsBackground = true;
			}
			
			if(!_listenerThread.IsAlive)
				_listenerThread.Start();
			
			_bListening = true;
		}