예제 #1
0
        public KernelResult ConnectLight(out KLightClientSession clientSession)
        {
            clientSession = null;

            KProcess currentProcess = KernelContext.Scheduler.GetCurrentProcess();

            if (currentProcess.ResourceLimit != null &&
                !currentProcess.ResourceLimit.Reserve(LimitableResource.Session, 1))
            {
                return(KernelResult.ResLimitExceeded);
            }

            if (!IncrementSessionsCount())
            {
                currentProcess.ResourceLimit?.Release(LimitableResource.Session, 1);

                return(KernelResult.SessionCountExceeded);
            }

            KLightSession session = new KLightSession(KernelContext);

            KernelResult result = _parent.EnqueueIncomingLightSession(session.ServerSession);

            if (result != KernelResult.Success)
            {
                session.ClientSession.DecrementReferenceCount();
                session.ServerSession.DecrementReferenceCount();

                return(result);
            }

            clientSession = session.ClientSession;

            return(result);
        }
예제 #2
0
        public KLightSession(Horizon system) : base(system)
        {
            ServerSession = new KLightServerSession(system, this);
            ClientSession = new KLightClientSession(system, this);

            _hasBeenInitialized = true;
        }
예제 #3
0
        public KernelResult ConnectLight(out KLightClientSession clientSession)
        {
            clientSession = null;

            KProcess currentProcess = System.Scheduler.GetCurrentProcess();

            if (currentProcess.ResourceLimit != null &&
                !currentProcess.ResourceLimit.Reserve(LimitableResource.Session, 1))
            {
                return(KernelResult.ResLimitExceeded);
            }

            lock (_countIncLock)
            {
                if (_sessionsCount < _maxSessions)
                {
                    _sessionsCount++;
                }
                else
                {
                    currentProcess.ResourceLimit?.Release(LimitableResource.Session, 1);

                    return(KernelResult.SessionCountExceeded);
                }
            }

            KLightSession session = new KLightSession(System);

            KernelResult result = _parent.EnqueueIncomingLightSession(session.ServerSession);

            if (result != KernelResult.Success)
            {
                session.ClientSession.DecrementReferenceCount();
                session.ServerSession.DecrementReferenceCount();

                return(result);
            }

            clientSession = session.ClientSession;

            return(result);
        }
예제 #4
0
 public KLightSession(Horizon system) : base(system)
 {
     ServerSession = new KLightServerSession(system, this);
     ClientSession = new KLightClientSession(system, this);
 }
예제 #5
0
 public KLightSession(KernelContext context) : base(context)
 {
     ServerSession = new KLightServerSession(context, this);
     ClientSession = new KLightClientSession(context, this);
 }