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); }
public KLightSession(Horizon system) : base(system) { ServerSession = new KLightServerSession(system, this); ClientSession = new KLightClientSession(system, this); _hasBeenInitialized = true; }
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); }
public KLightSession(Horizon system) : base(system) { ServerSession = new KLightServerSession(system, this); ClientSession = new KLightClientSession(system, this); }
public KLightSession(KernelContext context) : base(context) { ServerSession = new KLightServerSession(context, this); ClientSession = new KLightClientSession(context, this); }