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

Unified Diff: runtime/platform/thread_win.cc

Issue 9196002: Move Mutex and Monitor from vm/ to platform/ (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 months 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
Index: runtime/platform/thread_win.cc
diff --git a/runtime/vm/thread_win.cc b/runtime/platform/thread_win.cc
similarity index 60%
copy from runtime/vm/thread_win.cc
copy to runtime/platform/thread_win.cc
index c763babd4de6ef9801e9231d26868ef537a483f6..048b2cc3590d059f4925986b680d92fa535f2443 100644
--- a/runtime/vm/thread_win.cc
+++ b/runtime/platform/thread_win.cc
@@ -5,68 +5,10 @@
#include <process.h>
#include "platform/assert.h"
-#include "vm/thread.h"
+#include "platform/thread.h"
namespace dart {
-class ThreadStartData {
- public:
- ThreadStartData(Thread::ThreadStartFunction function,
- uword parameter,
- Thread* thread)
- : function_(function), parameter_(parameter), thread_(thread) {}
-
- Thread::ThreadStartFunction function() const { return function_; }
- uword parameter() const { return parameter_; }
- Thread* thread() const { return thread_; }
-
- private:
- Thread::ThreadStartFunction function_;
- uword parameter_;
- Thread* thread_;
-
- DISALLOW_COPY_AND_ASSIGN(ThreadStartData);
-};
-
-
-// Dispatch to the thread start function provided by the caller. This trampoline
-// is used to ensure that the thread is properly destroyed if the thread just
-// exits.
-static unsigned int __stdcall ThreadEntry(void* data_ptr) {
- ThreadStartData* data = reinterpret_cast<ThreadStartData*>(data_ptr);
-
- Thread::ThreadStartFunction function = data->function();
- uword parameter = data->parameter();
- Thread* thread = data->thread();
- delete data;
-
- // Call the supplied thread start function handing it its parameters.
- function(parameter);
-
- // When the function returns here, make sure that the thread is deleted.
- delete thread;
-
- return 0;
-}
-
-
-Thread::Thread(ThreadStartFunction function, uword parameter) {
- ThreadStartData* start_data = new ThreadStartData(function, parameter, this);
- uint32_t tid;
- data_.thread_handle_ =
- _beginthreadex(NULL, 64 * KB, ThreadEntry, start_data, 0, &tid);
- if (data_.thread_handle_ == -1) {
- FATAL("Thread creation failed");
- }
- data_.tid_ = tid;
-}
-
-
-Thread::~Thread() {
- CloseHandle(reinterpret_cast<HANDLE>(data_.thread_handle_));
-}
-
-
Mutex::Mutex() {
// Allocate unnamed semaphore with initial count 1 and max count 1.
data_.semaphore_ = CreateSemaphore(NULL, 1, 1, NULL);

Powered by Google App Engine
This is Rietveld 408576698