public InterleavingStreamPacketProcessor() { transfers = new byte[MaxParallelTransfers][]; offsets = new int[MaxParallelTransfers]; foreach (var id in Enumerable.Range(0, MaxParallelTransfers)) { freeIds.Enqueue((byte)(MaxParallelTransfers - id)); } }
/// <summary> /// Enqueues a log message to be written to main chat logfile. /// Only if the Logger is started. /// </summary> /// <param name="Text"></param> public static void LogChat(string Text) { if (isRunning && isChatLogEnabled && inputQueueChat != null) { inputQueueChat.Enqueue(String.Copy(Text)); } }
/// <summary> /// Enqueues a log message to be written to main logfile. /// Only if the Logger is started. /// </summary> /// <param name="Module"></param> /// <param name="Type"></param> /// <param name="Message"></param> public static void Log(string Module, LogType Type, string Message) { if (isRunning && inputQueue != null) { inputQueue.Enqueue(new LogMessage(Module, Type, Message)); } }
/// <summary> /// Stars loading all objects in a background thread. /// </summary> protected void LoadThreadObjects() { IEnumerator <KeyValuePair <string, BgfFile> > it = Objects.GetEnumerator(); BgfFile file; while (it.MoveNext()) { // load file = new BgfFile(Path.Combine(ObjectsFolder, it.Current.Key)); file.DecompressAll(); // update Objects.TryUpdate(it.Current.Key, file, null); queueAsyncFilesLoaded.Enqueue(it.Current.Key); } }
/// <summary> /// Executed by internal worker thread /// </summary> protected void ThreadProc() { // start listening for tcp connections listener.Start(); // loop while (isRunning) { // wait for connection request (will block) TcpClient tcpClient = listener.AcceptTcpClient(); // enqueue new connection IncomingConnections.Enqueue(tcpClient); } // stop listening for tcp connections listener.Stop(); }
public void AddForce(Force f) { forces.Enqueue(f); }
public void AddJob(Action action) { _jobQueue.Enqueue(action); SignalJobIsReady(); }