示例#1
0
文件: ThreadOps.cs 项目: ltwlf/IronSP
        public static Thread Kill(Thread /*!*/ self)
        {
            RubyThreadInfo.RegisterThread(Thread.CurrentThread);
            RubyThreadInfo info = RubyThreadInfo.FromThread(self);

            if (GetStatus(self) == RubyThreadStatus.Sleeping && info.ExitRequested)
            {
                // Thread must be sleeping in an ensure clause. Wake up the thread and allow ensure clause to complete
                info.Run();
                return(self);
            }

            info.ExitRequested = true;
            RubyUtils.ExitThread(self);
            return(self);
        }