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

Side by Side Diff: runtime/bin/eventhandler.h

Issue 9112013: Thread pool changes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 10
10 // Flags used to provide information and actions to the eventhandler 11 // Flags used to provide information and actions to the eventhandler
11 // when sending a message about a file descriptor. These flags should 12 // when sending a message about a file descriptor. These flags should
12 // be kept in sync with the constants in socket_impl.dart. For more 13 // be kept in sync with the constants in socket_impl.dart. For more
13 // information see the comments in socket_impl.dart 14 // information see the comments in socket_impl.dart
14 enum MessageFlags { 15 enum MessageFlags {
15 kInEvent = 0, 16 kInEvent = 0,
16 kOutEvent = 1, 17 kOutEvent = 1,
17 kErrorEvent = 2, 18 kErrorEvent = 2,
18 kCloseEvent = 3, 19 kCloseEvent = 3,
(...skipping 15 matching lines...) Expand all
34 #else 35 #else
35 #error Unknown target os. 36 #error Unknown target os.
36 #endif 37 #endif
37 38
38 class EventHandler { 39 class EventHandler {
39 public: 40 public:
40 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) {
41 delegate_.SendData(id, dart_port, data); 42 delegate_.SendData(id, dart_port, data);
42 } 43 }
43 44
45 static void* AsyncTaskHandler(void* args) {
46 if (Dart_IsVMFlagSet("trace_thread_pool")) {
47 printf("Got async task\n");
48 }
49 return NULL;
50 }
51
52 static void Initialize() {
53 if (Dart_IsVMFlagSet("enable_thread_pool")) {
54 ASSERT(thread_pool_ == NULL);
55 thread_pool_ = new ThreadPool(&EventHandler::AsyncTaskHandler);
56 thread_pool_->Start();
57 }
58 }
59
44 static EventHandler* StartEventHandler() { 60 static EventHandler* StartEventHandler() {
45 EventHandler* handler = new EventHandler(); 61 EventHandler* handler = new EventHandler();
46 handler->delegate_.StartEventHandler(); 62 handler->delegate_.StartEventHandler();
47 return handler; 63 return handler;
48 } 64 }
49 65
50 private: 66 private:
51 EventHandlerImplementation delegate_; 67 EventHandlerImplementation delegate_;
68 static ThreadPool* thread_pool_;
52 }; 69 };
53 70
54 71
55 #endif // BIN_EVENTHANDLER_H_ 72 #endif // BIN_EVENTHANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698