[runtime] Allow getting thread name, managed id from embedding API
authorJonathan Pryor <jonpryor@vt.edu>
Mon, 25 Jan 2016 18:42:32 +0000 (13:42 -0500)
committerJonathan Pryor <jonpryor@vt.edu>
Mon, 25 Jan 2016 19:29:00 +0000 (14:29 -0500)
commitbbe1010ef4f51bd7c1be884194c93317aadb49c5
tree7ef02e1098df904b16feb193afc905aeb149912c
parentc5b1a68cbaeeeca101a4ed7703acaec349d41455
[runtime] Allow getting thread name, managed id from embedding API

When tracing multi-threaded program execution, it is useful to have a
way of separating which events happen on which thread. The
System.Threading.Thread.Name and Thread.ManagedThreadId properties are
useful proxies for tracking program execution.

However, if program execution spans both managed and embedded mono
native code, there is no existing mechanism to read the Thread.Name or
Thread.ManagedThreadId properties from native code without using
delegates, and delegates may not be usable in all circumstances (e.g.
within a mono_gc_register_bridge_callbacks() callback).

Add the following APIs to the embedding API to permit reading the
Thread.Name and Thread.ManagedThreadId properties:

char   *mono_thread_get_name_utf8 (MonoThread *thread);
gint32  mono_thread_get_managed_id (MonoThread *thread);

mono_thread_get_name_utf8() returns the Thread.Name value as a UTF-8
string in newly allocated memory; the caller must g_free() this value.

mono_thread_get_managed_id() returns the Thread.ManagedThreadId value.
docs/public-api
mono/metadata/threads.c
mono/metadata/threads.h
msvc/mono.def
msvc/monosgen.def