Example #1
0
        private void dump(OpeLog logger, TextWriter w)
        {
            string msg;

            msg = String.Format("status={0}", (thread != null)?thread.ThreadState.ToString():"Disposed");
            if (logger != null)
            {
                logger.Log("NThread[" + this.Name + "]", OpeLog.Level.DEBUG, msg);
            }
            if (w != null)
            {
                w.WriteLine("NThread[" + this.Name + "]: " + msg);
            }
            if ((watchdogThread != null) && (watchdogTimer != null))
            {
                msg = String.Format("watchdog: mode={0}, timeout={1}msec, timer={2}msec", watchdogMode.ToString(), (watchdogTimeout == long.MaxValue)?"inf.":watchdogTimeout.ToString(), watchdogTimer.ElapsedMilliseconds);
                if (logger != null)
                {
                    logger.Log("        ", OpeLog.Level.DEBUG, msg);
                }
                if (w != null)
                {
                    w.WriteLine("        " + msg);
                }
            }
        }
Example #2
0
 /// <summary>
 ///   NThreadの一覧をデバッグログに書き出す
 /// </summary>
 public static void DumpAll(OpeLog logger)
 {
     lock (threadDict) {
         logger.Log("NThread", OpeLog.Level.DEBUG, "total {0} threads", threadDict.Count);
         foreach (NThread nth in threadDict.Values)
         {
             nth.Dump(logger);
         }
     }
 }
Example #3
0
            private void show(string timeTitle, long t)
            {
                if (title == null)
                {
                    return;
                }
                string msg = String.Format("{1,7:N0}msec {0}", title, t);

                if (logger != null)
                {
                    logger.Log(timeTitle + threadName, OpeLog.Level.DEBUG, msg);
                }
                if (writer != null)
                {
                    writer.WriteLine("{0}{1}: {2}", timeTitle, threadName, msg);
                }
            }
Example #4
0
 private static void dumpAll(OpeLog logger, TextWriter w, bool full)
 {
     RWLock[] list;
     lock (globalRWLockList) {
         list = globalRWLockList.ToArray();
     }
     Array.Sort(list, delegate(RWLock a, RWLock b){
         return(a.Name.CompareTo(b.Name));
     });
     if (logger != null)
     {
         logger.Log("RWLock", OpeLog.Level.DEBUG, "total {0} locks", list.Length);
     }
     if (w != null)
     {
         w.WriteLine("RWLock: total {0} locks", list.Length);
     }
     foreach (RWLock rwlock in list)
     {
         rwlock.dump(logger, w, full);
     }
 }
Example #5
0
 private void dump(OpeLog logger, TextWriter w, bool full)
 {
     if (!full && (this.CurrentReadCount == 0) && !this.IsWriteLockHeld && !this.IsUpgradeableReadLockHeld)
     {
         return;
     }
     if (logger != null)
     {
         logger.Log("RWLock[" + this.Name + "]", OpeLog.Level.DEBUG,
                    "reading {0}, writing {1}, u-reading {2}",
                    this.CurrentReadCount, this.IsWriteLockHeld?1:0, this.IsUpgradeableReadLockHeld?1:0);
     }
     if (w != null)
     {
         w.WriteLine("RWLock[{0}]: reading {1}, writing {2}, u-reading {3}",
                     this.Name, this.CurrentReadCount, this.IsWriteLockHeld?1:0, this.IsUpgradeableReadLockHeld?1:0);
     }
     if ((readingThread != null) && (readingThread.Count > 0))
     {
         StringBuilder sb = new StringBuilder("reading:");
         foreach (Thread t in readingThread)
         {
             sb.Append(' ');
             sb.Append(String.IsNullOrEmpty(t.Name)?t.ManagedThreadId.ToString():t.Name);
         }
         if (logger != null)
         {
             logger.Log("RWLock[" + this.Name + "]", OpeLog.Level.DEBUG, sb.ToString());
         }
         if (w != null)
         {
             w.WriteLine("RWLock[{0}]: {1}", this.Name, sb.ToString());
         }
     }
     if ((writingThread != null) && (writingThread.Count > 0))
     {
         StringBuilder sb = new StringBuilder("writing:");
         foreach (Thread t in writingThread)
         {
             sb.Append(' ');
             sb.Append(String.IsNullOrEmpty(t.Name)?t.ManagedThreadId.ToString():t.Name);
         }
         if (logger != null)
         {
             logger.Log("RWLock[" + this.Name + "]", OpeLog.Level.DEBUG, sb.ToString());
         }
         if (w != null)
         {
             w.WriteLine("RWLock[{0}]: {1}", this.Name, sb.ToString());
         }
     }
     if ((upgradeableReadingThread != null) && (upgradeableReadingThread.Count > 0))
     {
         StringBuilder sb = new StringBuilder("upgradeableReading:");
         foreach (Thread t in upgradeableReadingThread)
         {
             sb.Append(' ');
             sb.Append(String.IsNullOrEmpty(t.Name)?t.ManagedThreadId.ToString():t.Name);
         }
         if (logger != null)
         {
             logger.Log("RWLock[" + this.Name + "]", OpeLog.Level.DEBUG, sb.ToString());
         }
         if (w != null)
         {
             w.WriteLine("RWLock[{0}]: {1}", this.Name, sb.ToString());
         }
     }
     if ((waitingReadThread != null) && (waitingReadThread.Count > 0))
     {
         StringBuilder sb = new StringBuilder("waiting read:");
         foreach (Thread t in waitingReadThread)
         {
             sb.Append(' ');
             sb.Append(String.IsNullOrEmpty(t.Name)?t.ManagedThreadId.ToString():t.Name);
         }
         if (logger != null)
         {
             logger.Log("RWLock[" + this.Name + "]", OpeLog.Level.DEBUG, sb.ToString());
         }
         if (w != null)
         {
             w.WriteLine("RWLock[{0}]: {1}", this.Name, sb.ToString());
         }
     }
     if ((waitingWriteThread != null) && (waitingWriteThread.Count > 0))
     {
         StringBuilder sb = new StringBuilder("waiting read:");
         foreach (Thread t in waitingWriteThread)
         {
             sb.Append(' ');
             sb.Append(String.IsNullOrEmpty(t.Name)?t.ManagedThreadId.ToString():t.Name);
         }
         if (logger != null)
         {
             logger.Log("RWLock[" + this.Name + "]", OpeLog.Level.DEBUG, sb.ToString());
         }
         if (w != null)
         {
             w.WriteLine("RWLock[{0}]: {1}", this.Name, sb.ToString());
         }
     }
     if ((waitingUpgradeableReadThread != null) && (waitingUpgradeableReadThread.Count > 0))
     {
         StringBuilder sb = new StringBuilder("waiting read:");
         foreach (Thread t in waitingUpgradeableReadThread)
         {
             sb.Append(' ');
             sb.Append(String.IsNullOrEmpty(t.Name)?t.ManagedThreadId.ToString():t.Name);
         }
         if (logger != null)
         {
             logger.Log("RWLock[" + this.Name + "]", OpeLog.Level.DEBUG, sb.ToString());
         }
         if (w != null)
         {
             w.WriteLine("RWLock[{0}]: {1}", this.Name, sb.ToString());
         }
     }
 }