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

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: Added tread pool shutdown 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
« no previous file with comments | « runtime/bin/builtin_sources.gypi ('k') | runtime/bin/eventhandler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
60 static void Terminate() {
61 if (Dart_IsVMFlagSet("enable_thread_pool")) {
62 if (thread_pool_ != NULL) {
63 thread_pool_->Shutdown();
64 }
65 }
66 }
67
44 static EventHandler* StartEventHandler() { 68 static EventHandler* StartEventHandler() {
45 EventHandler* handler = new EventHandler(); 69 EventHandler* handler = new EventHandler();
46 handler->delegate_.StartEventHandler(); 70 handler->delegate_.StartEventHandler();
47 return handler; 71 return handler;
48 } 72 }
49 73
50 private: 74 private:
51 EventHandlerImplementation delegate_; 75 EventHandlerImplementation delegate_;
76 static ThreadPool* thread_pool_;
52 }; 77 };
53 78
54 79
55 #endif // BIN_EVENTHANDLER_H_ 80 #endif // BIN_EVENTHANDLER_H_
OLDNEW
« no previous file with comments | « runtime/bin/builtin_sources.gypi ('k') | runtime/bin/eventhandler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698