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

Unified Diff: runtime/vm/os_thread_win.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_macos.cc ('k') | runtime/vm/profiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/os_thread_win.cc
diff --git a/runtime/vm/os_thread_win.cc b/runtime/vm/os_thread_win.cc
index fd8de38685fb401c88f85457d9994ed19673c1d9..c46405ae1f68c69edb74ad35e9af59f0b59b2b4b 100644
--- a/runtime/vm/os_thread_win.cc
+++ b/runtime/vm/os_thread_win.cc
@@ -20,13 +20,17 @@ bool private_flag_windows_run_tls_destructors = true;
class ThreadStartData {
public:
- ThreadStartData(OSThread::ThreadStartFunction function, uword parameter)
- : function_(function), parameter_(parameter) {}
+ ThreadStartData(const char* name,
+ OSThread::ThreadStartFunction function,
+ uword 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_;
@@ -40,12 +44,18 @@ class ThreadStartData {
static unsigned int __stdcall ThreadEntry(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;
MonitorData::GetMonitorWaitDataForThread();
+ // 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);
@@ -56,8 +66,10 @@ static unsigned int __stdcall ThreadEntry(void* data_ptr) {
}
-int OSThread::Start(ThreadStartFunction function, uword parameter) {
- ThreadStartData* start_data = new ThreadStartData(function, parameter);
+int OSThread::Start(const char* name,
+ ThreadStartFunction function,
+ uword parameter) {
+ ThreadStartData* start_data = new ThreadStartData(name, function, parameter);
uint32_t tid;
uintptr_t thread = _beginthreadex(NULL, OSThread::GetMaxStackSize(),
ThreadEntry, start_data, 0, &tid);
@@ -115,6 +127,8 @@ ThreadId OSThread::GetCurrentThreadTraceId() {
ThreadJoinId OSThread::GetCurrentThreadJoinId() {
+ // TODO(zra): Use the thread handle as the join id in order to have a more
+ // reliable join on windows.
return ::GetCurrentThreadId();
}
« no previous file with comments | « runtime/vm/os_thread_macos.cc ('k') | runtime/vm/profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698