Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1651)

Unified Diff: runtime/vm/os_thread_linux.cc

Issue 1439483003: - Add an OSThread structure which is the generic TLS structure for all C++ (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/os_thread_android.cc ('k') | runtime/vm/os_thread_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/os_thread_linux.cc
diff --git a/runtime/vm/os_thread_linux.cc b/runtime/vm/os_thread_linux.cc
index f48b6b015ea59c36c2f334aed091bb0e3893a454..470c3e348a265d3aa3ba965d6b6f17c884d1c9e7 100644
--- a/runtime/vm/os_thread_linux.cc
+++ b/runtime/vm/os_thread_linux.cc
@@ -78,14 +78,17 @@ static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) {
class ThreadStartData {
public:
- ThreadStartData(OSThread::ThreadStartFunction function,
+ ThreadStartData(const char* name,
+ OSThread::ThreadStartFunction function,
uword parameter)
- : function_(function), parameter_(parameter) {}
+ : name_(name), function_(function), parameter_(parameter) {}
+ const char* name() const { return name_; }
OSThread::ThreadStartFunction function() const { return function_; }
uword parameter() const { return parameter_; }
private:
+ const char* name_;
OSThread::ThreadStartFunction function_;
uword parameter_;
@@ -99,10 +102,16 @@ class ThreadStartData {
static void* ThreadStart(void* data_ptr) {
ThreadStartData* data = reinterpret_cast<ThreadStartData*>(data_ptr);
+ const char* name = data->name();
OSThread::ThreadStartFunction function = data->function();
uword parameter = data->parameter();
delete data;
+ // Create new OSThread object and set as TLS for new thread.
+ OSThread* thread = new OSThread();
+ OSThread::SetCurrent(thread);
+ thread->set_name(name);
+
// Call the supplied thread start function handing it its parameters.
function(parameter);
@@ -110,7 +119,9 @@ static void* ThreadStart(void* data_ptr) {
}
-int OSThread::Start(ThreadStartFunction function, uword parameter) {
+int OSThread::Start(const char* name,
+ ThreadStartFunction function,
+ uword parameter) {
pthread_attr_t attr;
int result = pthread_attr_init(&attr);
RETURN_ON_PTHREAD_FAILURE(result);
@@ -118,7 +129,7 @@ int OSThread::Start(ThreadStartFunction function, uword parameter) {
result = pthread_attr_setstacksize(&attr, OSThread::GetMaxStackSize());
RETURN_ON_PTHREAD_FAILURE(result);
- ThreadStartData* data = new ThreadStartData(function, parameter);
+ ThreadStartData* data = new ThreadStartData(name, function, parameter);
pthread_t tid;
result = pthread_create(&tid, &attr, ThreadStart, data);
« no previous file with comments | « runtime/vm/os_thread_android.cc ('k') | runtime/vm/os_thread_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698