OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef BIN_EVENTHANDLER_H_ | 5 #ifndef BIN_EVENTHANDLER_H_ |
6 #define BIN_EVENTHANDLER_H_ | 6 #define BIN_EVENTHANDLER_H_ |
7 | 7 |
8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
9 #include "bin/thread_pool.h" | 9 #include "bin/thread_pool.h" |
10 | 10 |
11 // Flags used to provide information and actions to the eventhandler | 11 // Flags used to provide information and actions to the eventhandler |
(...skipping 23 matching lines...) Expand all Loading... |
35 #else | 35 #else |
36 #error Unknown target os. | 36 #error Unknown target os. |
37 #endif | 37 #endif |
38 | 38 |
39 class EventHandler { | 39 class EventHandler { |
40 public: | 40 public: |
41 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data) { | 41 void SendData(intptr_t id, Dart_Port dart_port, intptr_t data) { |
42 delegate_.SendData(id, dart_port, data); | 42 delegate_.SendData(id, dart_port, data); |
43 } | 43 } |
44 | 44 |
45 static void* AsyncTaskHandler(void* args) { | 45 static void AsyncTaskHandler(ThreadPool::Task args) { |
46 if (Dart_IsVMFlagSet("trace_thread_pool")) { | 46 if (Dart_IsVMFlagSet("trace_thread_pool")) { |
47 printf("Got async task\n"); | 47 printf("Got async task\n"); |
48 } | 48 } |
49 return NULL; | |
50 } | 49 } |
51 | 50 |
52 static void Initialize() { | 51 static void Initialize() { |
53 if (Dart_IsVMFlagSet("enable_thread_pool")) { | 52 if (Dart_IsVMFlagSet("enable_thread_pool")) { |
54 ASSERT(thread_pool_ == NULL); | 53 ASSERT(thread_pool_ == NULL); |
55 thread_pool_ = new ThreadPool(&EventHandler::AsyncTaskHandler); | 54 thread_pool_ = new ThreadPool(&EventHandler::AsyncTaskHandler); |
56 thread_pool_->Start(); | 55 thread_pool_->Start(); |
57 } | 56 } |
58 } | 57 } |
59 | 58 |
(...skipping 11 matching lines...) Expand all Loading... |
71 return handler; | 70 return handler; |
72 } | 71 } |
73 | 72 |
74 private: | 73 private: |
75 EventHandlerImplementation delegate_; | 74 EventHandlerImplementation delegate_; |
76 static ThreadPool* thread_pool_; | 75 static ThreadPool* thread_pool_; |
77 }; | 76 }; |
78 | 77 |
79 | 78 |
80 #endif // BIN_EVENTHANDLER_H_ | 79 #endif // BIN_EVENTHANDLER_H_ |
OLD | NEW |