Project

General

Profile

Feature #11251

Thread#name and Thread#name=

Added by naruse (Yui NARUSE) about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-dev:49068]

Description

Threadの名前の取得・設定を行うAPIを追加しませんか。

#6694#6695 などで断続的に議論がなされ、r47670 で一部自動で名前が付けられるようになったりもしていますが、
Rubyレベルでそれを見る手段は提供されていませんし、明示的に付けることも出来ません。

今でもニーズは結構あるようです。

"Fluentdでどのスレッドがどのプラグインに属しているのかが簡単に分かるようになるんですよね”
https://twitter.com/repeatedly/status/608855851131011073
"確かにRubyのスレッドに名前付けられたら良さそう。主にログで識別する用途で。"
https://twitter.com/frsyuki/status/608863065598140417

Linux (glibc 2.12+)
 int pthread_setname_np(pthread_t thread, const char *name);
 int pthread_getname_np(pthread_t thread, char *name, size_t len);
FreeBSD
 void pthread_set_name_np(pthread_t, const char *);
NetBSD
 int pthread_getname_np(pthread_t thread, char *name, size_t len);
 int pthread_setname_np(pthread_t thread, const char *name, void *arg);
 http://netbsd.gw.com/cgi-bin/man-cgi?pthread_setname_np++NetBSD-current
OS X
 /usr/include/pthread/pthread.h:int pthread_getname_np(pthread_t,char*,size_t);
 /usr/include/pthread/pthread.h:int pthread_setname_np(const char*);

Related issues

Related to Ruby master - Feature #6694: Thread.new without block.AssignedActions
Related to Ruby master - Feature #6695: Configuration for Thread/Fiber creationAssignedActions

Associated revisions

Revision e2a930c7
Added by naruse (Yui NARUSE) about 4 years ago

add Thread.name and Thread.name= docs Feature #11251 [ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 50868
Added by naruse (Yui NARUSE) about 4 years ago

add Thread.name and Thread.name= docs Feature #11251 [ci skip]

Revision 50868
Added by naruse (Yui NARUSE) about 4 years ago

add Thread.name and Thread.name= docs Feature #11251 [ci skip]

Revision 50868
Added by naruse (Yui NARUSE) about 4 years ago

add Thread.name and Thread.name= docs Feature #11251 [ci skip]

Revision 50868
Added by naruse (Yui NARUSE) about 4 years ago

add Thread.name and Thread.name= docs Feature #11251 [ci skip]

Revision 50868
Added by naruse (Yui NARUSE) about 4 years ago

add Thread.name and Thread.name= docs Feature #11251 [ci skip]

History

Updated by nobu (Nobuyoshi Nakada) about 4 years ago

  • Description updated (diff)
#2

Updated by naruse (Yui NARUSE) about 4 years ago

#3

Updated by naruse (Yui NARUSE) about 4 years ago

  • Related to Feature #6695: Configuration for Thread/Fiber creation added

Updated by matz (Yukihiro Matsumoto) about 4 years ago

いいよ。
Having Thread#name and Thread#name= is OK for me. Concrete behavior should be implementation defined.

Matz.

#5

Updated by naruse (Yui NARUSE) about 4 years ago

  • Status changed from Open to Closed

Applied in changeset r50868.


add Thread.name and Thread.name= docs Feature #11251 [ci skip]

Also available in: Atom PDF