/// <summary>
 /// Dispose managed resources.
 /// </summary>
 /// <param name="disposing">Is desposing.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (disposing)
         {
             CancelPolling();
             if (pubSocket != null)
             {
                 pubSocket.Disconnect(PublisherAddress);
                 pubSocket.Dispose();
                 pubSocket = null;
             }
             if (poller != null)
             {
                 poller.Dispose();
                 poller = null;
             }
             if (context != null)
             {
                 context.Terminate();
                 context.Dispose();
                 context = null;
             }
             if (source != null)
             {
                 source.Dispose();
                 source = null;
             }
         }
         // Shared cleanup logic.
         disposed = true;
     }
 }
Beispiel #2
0
        public void Dispose()
        {
            Disconnect();

            if (_reqSocket != null)
            {
                _reqSocket.Dispose();
                _reqSocket = null;
            }
            if (_subSocket != null)
            {
                _subSocket.Dispose();
                _subSocket = null;
            }
            if (_dealerSocket != null)
            {
                _dealerSocket.Dispose();
                _dealerSocket = null;
            }
            if (_heartBeatTimer != null)
            {
                _heartBeatTimer.Dispose();
                _heartBeatTimer = null;
            }
            //The context must be disposed of last! It will hang if the sockets have not been disposed.
            if (_context != null)
            {
                _context.Dispose();
                _context = null;
            }
        }
Beispiel #3
0
        public void Dispose()
        {
            lock (this)
            {
                if (!m_isDisposed)
                {
                    SharpDBConnection connection;

                    while (m_connections.TryTake(out connection))
                    {
                        connection.Dispose();
                    }

                    if (m_contextOwned)
                    {
                        m_context.Dispose();
                    }

                    m_connections = null;
                    m_context     = null;

                    m_isDisposed = true;
                }
            }
        }
Beispiel #4
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_publisherSocket != null)
                {
                    _publisherSocket.Dispose();
                    _publisherSocket = null;
                }

                foreach (NetMQSocket subscriber in _subscriberSockets.ToArray())
                {
                    subscriber.Dispose();
                    _subscriberSockets.Remove(subscriber);
                }

                // Setting running to false will stop the subscriber tasks
                _running = false;

                if (_context != null)
                {
                    _context.Dispose();
                    _context = null;
                }
            }
            base.Dispose(disposing);
        }
Beispiel #5
0
 private void Dispose(bool isDisposing)
 {
     if (isDisposing)
     {
         socketFactory?.Dispose();
     }
 }
Beispiel #6
0
 public void Dispose()
 {
     _scheduler.Dispose();
     _client.Dispose();
     _poller.CancelAndJoin();
     _poller.Dispose();
     _context.Dispose();
 }
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         subSocket?.Dispose();
         context?.Dispose();
     }
 }
Beispiel #8
0
        public void Dispose()
        {
            _poller.Stop(false);

            _poller.RemoveTimer(_timer);
            _poller.Dispose();
            _context.Dispose();
        }
Beispiel #9
0
 public void Dispose()
 {
     _ctx.Dispose();
     if (_sharedQueue == null)
     {
         throw new ApplicationException("Impossible exception: only used to trick compilation optimization with unused variable _sharedQueue.");
     }
 }
        public void Stop()
        {
            isRunning = false;
            subscribeSocket.Close();
            ctx.Dispose();

            receiveThread.Join(100);
            logger.Info("Server message subscriber stopped");
        }
Beispiel #11
0
 protected override void OnStopped()
 {
     base.OnStopped();
     _pullSocket.Close();
     _pullSocket.Dispose();
     _pushSocket.Close();
     _pushSocket.Dispose();
     _netMqContext.Dispose();
 }
 public void Dispose()
 {
     _clientSocket.Dispose();
     _context.Dispose();
     if (task != null)
     {
         task.Dispose();
     }
 }
Beispiel #13
0
 public void Stop()
 {
     _running = false;
     if (_socket != null && _context != null)
     {
         _socket.Close();
         _context.Dispose();
     }
 }
Beispiel #14
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         Socket.Dispose();
         m_ctx.Dispose();
     }
     // get rid of unmanaged resources
 }
Beispiel #15
0
        public void Stop()
        {
            isRunning = false;
            responseSocket.Close();
            ctx.Dispose();

            listenThread.Join(100);
            logger.Info("Message puller has stopped");
        }
Beispiel #16
0
 public void Dispose()
 {
     if (disposed)
     {
         return;
     }
     disposed = true;
     zeroMQContext.Dispose();
 }
Beispiel #17
0
 public void Dispose()
 {
     _isStart = false;
     _serverSocket.Dispose();
     _context.Dispose();
     if (task != null)
     {
         task.Dispose();
     }
 }
Beispiel #18
0
 protected void Cleanup()
 {
     ClientFiber.Enqueue(() =>
     {
         Send.Dispose();
         Context1.Dispose();
         Subscriber.Dispose();
         Context2.Dispose();
     });
     Thread.Sleep(100);
     ClientFiber.Dispose();
 }
Beispiel #19
0
        protected override void Dispose()
        {
            if (!disposed)
            {
                poller.Cancel();
                clientR.Dispose();
                clientS.Dispose();
                context.Dispose();

                disposed = true;
            }
        }
Beispiel #20
0
 void IDisposable.Dispose()
 {
     if (Interlocked.Increment(ref _disposeCount) != 1)
     {
         return;
     }
     Debug.WriteLine(string.Format("Disposing {0}...", this.GetType().Name));
     new Action(() => _socket.Options.Linger = TimeSpan.Zero).CaptureMqExceptions <TerminatingException>();
     new Action(() => _socket.Dispose()).CaptureMqExceptions();
     new Action(() => _context.Dispose()).CaptureMqExceptions();
     Console.WriteLine(string.Format("{0} disposed.", this.GetType().Name));
 }
Beispiel #21
0
        void IDisposable.Dispose()
        {
            if (Interlocked.Increment(ref _disposeCount) != 1)
            {
                return;
            }

            Debug.WriteLine(string.Format("Disposing {0}...", this.GetType().Name));

            _backgroundSocketTaskCts.Cancel();
            new Action(() => _context.Dispose()).CaptureMqExceptions();
            Console.WriteLine(string.Format("{0} disposed.", this.GetType().Name));
        }
Beispiel #22
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && socket != null)
            {
                socket.Dispose();
                socket = null;
            }

            if (disposing && context != null)
            {
                context.Dispose();
                context = null;
            }
        }
Beispiel #23
0
        public void Stop()
        {
            m_log.InfoFormat("Stopping SharpDB...");

            m_server.Stop();
            m_task.Wait();

            m_db.Stop();
            m_context.Dispose();

            m_server  = null;
            m_db      = null;
            m_context = null;
        }
Beispiel #24
0
        public void Dispose()
        {
            StopServer();

            if (_routerSocket != null)
            {
                _routerSocket.Dispose();
                _routerSocket = null;
            }
            if (_context != null)
            {
                _context.Dispose();
                _context = null;
            }
        }
 void IDisposable.Dispose()
 {
     tokenSource.Cancel();
     if (publisher != null)
     {
         publisher.Dispose();
     }
     if (receiver != null)
     {
         receiver.Dispose();
     }
     if (context != null)
     {
         context.Dispose();
     }
 }
Beispiel #26
0
 protected void Cleanup()
 {
     ClientFiber.Enqueue(() =>
     {
         Client.Dispose();
         ClientContext.Dispose();
         Thread.Sleep(10);
         Service.Dispose();
         ServerContext.Dispose();
     });
     Thread.Sleep(100);
     Console.WriteLine("Dispose client fiber");
     ClientFiber.Dispose();
     Console.WriteLine("Dispose service");
     ServerFiber.Dispose();
 }
Beispiel #27
0
 protected void Cleanup()
 {
     ClientFiber.Enqueue(() =>
     {
         Console.WriteLine("Dispose push");
         Push.Dispose();
         Context2.Dispose();
         Thread.Sleep(10);
         Console.WriteLine("Dispose pull");
         Pull.Dispose();
         Context1.Dispose();
         Thread.Sleep(10);
     });
     Thread.Sleep(200);
     ClientFiber.Dispose();
 }
Beispiel #28
0
        protected override void OnStop()
        {
            if (_reader != null)
            {
                _reader.Dispose();
            }

            if (_eventPublisher != null)
            {
                _eventPublisher.Dispose();
            }

            if (_context != null)
            {
                _context.Dispose();
            }
        }
Beispiel #29
0
        public void Dispose()
        {
            if (Interlocked.Increment(ref _disposeCount) != 1)
            {
                return;
            }

            try
            {
                _context.Dispose();
                _traces.Debug("IpcEventProxy disposed.");
            }
            catch (NetMQException ex)
            {
                _traces.Error(ex);
            }
        }
Beispiel #30
0
 void IDisposable.Dispose()
 {
     tokenSource.Cancel();
     if (subscriber != null)
     {
         subscriber.Unsubscribe(String.Empty);
         subscriber.Dispose();
     }
     if (sender != null)
     {
         sender.Dispose();
     }
     if (context != null)
     {
         context.Dispose();
     }
 }