Exemple #1
0
 public ProtocolInstance(Ice.Communicator communicator, short type, string protocol, bool secure)
 {
     communicator_  = communicator;
     traceLevel_    = communicator_.traceLevels().network;
     traceCategory_ = communicator_.traceLevels().networkCat;
     logger_        = communicator_.initializationData().logger;
     properties_    = communicator_.initializationData().properties;
     type_          = type;
     protocol_      = protocol;
     secure_        = secure;
 }
Exemple #2
0
        internal AsyncIOThread(Ice.Communicator communicator)
        {
            _communicator = communicator;

            _thread = new HelperThread(this);
            updateObserver();
            _thread.Start(Util.stringToThreadPriority(
                              communicator.initializationData().properties.getProperty("Ice.ThreadPriority")));
        }
Exemple #3
0
 internal EndpointHostResolver(Ice.Communicator communicator)
 {
     _communicator = communicator;
     _protocol     = communicator.protocolSupport();
     _preferIPv6   = communicator.preferIPv6();
     _thread       = new HelperThread(this);
     updateObserver();
     _thread.Start(Util.stringToThreadPriority(
                       communicator.initializationData().properties.getProperty("Ice.ThreadPriority")));
 }
Exemple #4
0
        public static InvocationObserver get(Ice.Communicator communicator, string op)
        {
            CommunicatorObserver obsv = communicator.initializationData().observer;

            if (obsv != null)
            {
                InvocationObserver observer = obsv.getInvocationObserver(null, op, _emptyContext);
                if (observer != null)
                {
                    observer.attach();
                }
                return(observer);
            }
            return(null);
        }
Exemple #5
0
        //
        // Only for use by Instance.
        //
        internal Timer(Ice.Communicator communicator, ThreadPriority priority = ThreadPriority.Normal)
        {
            _communicator = communicator;

            string threadName = _communicator.initializationData().properties.getProperty("Ice.ProgramName");

            if (threadName.Length > 0)
            {
                threadName += "-";
            }

            _thread = new Thread(new ThreadStart(Run));
            _thread.IsBackground = true;
            _thread.Name         = threadName + "Ice.Timer";
            _thread.Priority     = priority;
            _thread.Start();
        }
Exemple #6
0
 internal PropertiesAdminI(Ice.Communicator communicator)
 {
     _properties = communicator.Properties;
     _logger     = communicator.initializationData().logger;
 }
Exemple #7
0
        public ThreadPool(Ice.Communicator communicator, string prefix, int timeout)
        {
            Ice.Properties properties = communicator.initializationData().properties;

            _communicator   = communicator;
            _dispatcher     = communicator.initializationData().dispatcher;
            _destroyed      = false;
            _prefix         = prefix;
            _threadIndex    = 0;
            _inUse          = 0;
            _serialize      = properties.getPropertyAsInt(_prefix + ".Serialize") > 0;
            _serverIdleTime = timeout;

            string programName = properties.getProperty("Ice.ProgramName");

            if (programName.Length > 0)
            {
                _threadPrefix = programName + "-" + _prefix;
            }
            else
            {
                _threadPrefix = _prefix;
            }

            //
            // We use just one thread as the default. This is the fastest
            // possible setting, still allows one level of nesting, and
            // doesn't require to make the servants thread safe.
            //
            int size = properties.getPropertyAsIntWithDefault(_prefix + ".Size", 1);

            if (size < 1)
            {
                string s = _prefix + ".Size < 1; Size adjusted to 1";
                _communicator.initializationData().logger.warning(s);
                size = 1;
            }

            int sizeMax = properties.getPropertyAsIntWithDefault(_prefix + ".SizeMax", size);

            if (sizeMax < size)
            {
                string s = _prefix + ".SizeMax < " + _prefix + ".Size; SizeMax adjusted to Size (" + size + ")";
                _communicator.initializationData().logger.warning(s);
                sizeMax = size;
            }

            int sizeWarn = properties.getPropertyAsInt(_prefix + ".SizeWarn");

            if (sizeWarn != 0 && sizeWarn < size)
            {
                string s = _prefix + ".SizeWarn < " + _prefix + ".Size; adjusted SizeWarn to Size (" + size + ")";
                _communicator.initializationData().logger.warning(s);
                sizeWarn = size;
            }
            else if (sizeWarn > sizeMax)
            {
                string s = _prefix + ".SizeWarn > " + _prefix + ".SizeMax; adjusted SizeWarn to SizeMax ("
                           + sizeMax + ")";
                _communicator.initializationData().logger.warning(s);
                sizeWarn = sizeMax;
            }

            int threadIdleTime = properties.getPropertyAsIntWithDefault(_prefix + ".ThreadIdleTime", 60);

            if (threadIdleTime < 0)
            {
                string s = _prefix + ".ThreadIdleTime < 0; ThreadIdleTime adjusted to 0";
                _communicator.initializationData().logger.warning(s);
                threadIdleTime = 0;
            }

            _size           = size;
            _sizeMax        = sizeMax;
            _sizeWarn       = sizeWarn;
            _threadIdleTime = threadIdleTime;

            int stackSize = properties.getPropertyAsInt(_prefix + ".StackSize");

            if (stackSize < 0)
            {
                string s = _prefix + ".StackSize < 0; Size adjusted to OS default";
                _communicator.initializationData().logger.warning(s);
                stackSize = 0;
            }
            _stackSize = stackSize;

            _priority = properties.getProperty(_prefix + ".ThreadPriority").Length > 0 ?
                        Util.stringToThreadPriority(properties.getProperty(_prefix + ".ThreadPriority")) :
                        Util.stringToThreadPriority(properties.getProperty("Ice.ThreadPriority"));

            if (_communicator.traceLevels().threadPool >= 1)
            {
                string s = "creating " + _prefix + ": Size = " + _size + ", SizeMax = " + _sizeMax + ", SizeWarn = " +
                           _sizeWarn;
                _communicator.initializationData().logger.trace(_communicator.traceLevels().threadPoolCat, s);
            }

            _workItems = new Queue <ThreadPoolWorkItem>();

            try
            {
                _threads = new List <WorkerThread>();
                for (int i = 0; i < _size; ++i)
                {
                    WorkerThread thread = new WorkerThread(this, _threadPrefix + "-" + _threadIndex++);
                    thread.start(_priority);
                    _threads.Add(thread);
                }
            }
            catch (System.Exception ex)
            {
                string s = "cannot create thread for `" + _prefix + "':\n" + ex;
                _communicator.initializationData().logger.error(s);

                destroy();
                joinWithAllThreads();
                throw;
            }
        }