Naming a Thread

I don’t know if this is a question or a feature request. In the course
of debuggind a Ruby application using threads I realize that it would be
great if we could give a name to a thread, i mean a human readable piece
of text that one could see when listing threads for instance.

Does this already exist? if not what about adding a new Thread#name=
and Thread#name instance methods in 1.7.x ?

Comments welcome

Laurent

Does this already exist? if not what about adding a new Thread#name=
and Thread#name instance methods in 1.7.x ?

Just use a thread local variable

Guy Decoux

ts wrote:

“L” == Laurent Julliard Laurent.Julliard@xrce.xerox.com writes:

Does this already exist? if not what about adding a new Thread#name=
and Thread#name instance methods in 1.7.x ?

Just use a thread local variable

Guy Decoux

This is an option of course. But in my case I’m writing a graphical
debugger and I want to display the threads of the debugged application
with their names. By definition I have no control over the name of the
local variable used by the author of the program to assign a label to
the thread. Hence the idea of having an “official” way of naimng threads.

Laurent

This is an option of course. But in my case I'm writing a graphical
debugger and I want to display the threads of the debugged application
with their names. By definition I have no control over the name of the
local variable used by the author of the program to assign a label to
the thread. Hence the idea of having an "official" way of naimng threads.

   class Thread
      def name
         self[:name]
      end
   
      def name=(a)
         self[:name] = a
      end
   end
   
Now you have an "official" way of naming threads :slight_smile:

Guy Decoux