Beispiel #1
0
        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);
        }