Project

General

Profile

Actions

Feature #11251

closed

Thread#name and Thread#name=

Added by naruse (Yui NARUSE) over 9 years ago. Updated over 9 years ago.

Status:
Closed
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 3 (2 open1 closed)

Related to Ruby master - Feature #6694: Thread.new without block.Assignedko1 (Koichi Sasada)Actions
Related to Ruby master - Feature #6695: Configuration for Thread/Fiber creationAssignedko1 (Koichi Sasada)Actions
Related to Ruby master - Feature #17853: Add Thread#thread_idClosedActions

Updated by nobu (Nobuyoshi Nakada) over 9 years ago

  • Description updated (diff)
Actions #2

Updated by naruse (Yui NARUSE) over 9 years ago

Actions #3

Updated by naruse (Yui NARUSE) over 9 years ago

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

Updated by matz (Yukihiro Matsumoto) over 9 years ago

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

Matz.

Actions #5

Updated by naruse (Yui NARUSE) over 9 years ago

  • Status changed from Open to Closed

Applied in changeset r50868.


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

Actions #6

Updated by naruse (Yui NARUSE) over 3 years ago

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0