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

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

Issue 24395013: Merge services into a shared IOService in dart:io, and use a native port. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Finish off native_service Created 7 years, 2 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/io_sources.gypi ('k') | runtime/bin/native_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 #ifndef BIN_NATIVE_SERVICE_H_
6 #define BIN_NATIVE_SERVICE_H_
7
8 #include "include/dart_api.h"
9 #include "include/dart_native_api.h"
10 #include "platform/globals.h"
11 #include "platform/thread.h"
12
13
14 namespace dart {
15 namespace bin {
16
17 // Utility class to set up a native service and allocate Dart native
18 // ports to interact with it from Dart code. The number of native ports
19 // allocated for each service is limited.
20 class NativeService {
21 public:
22 // Create a native service with the given name and handler. Allow
23 // the creation of [number_of_ports] native ports for the service.
24 // If GetServicePort is called more than [number_of_ports] times
25 // one of the already allocated native ports will be reused.
26 NativeService(const char* name,
27 Dart_NativeMessageHandler handler,
28 int number_of_ports);
29
30 ~NativeService();
31
32 // Get a Dart native port for this native service.
33 Dart_Port GetServicePort();
34
35 private:
36 // Name and handler for the native service.
37 const char* name_;
38 Dart_NativeMessageHandler handler_;
39
40 // Allocated native ports for the service. Mutex protected since
41 // the service can be used from multiple isolates.
42 dart::Mutex mutex_;
43 int service_ports_size_;
44 Dart_Port* service_ports_;
45 int service_ports_index_;
46
47 DISALLOW_IMPLICIT_CONSTRUCTORS(NativeService);
48 };
49
50 } // namespace bin
51 } // namespace dart
52
53 #endif // BIN_NATIVE_SERVICE_H_
OLDNEW
« no previous file with comments | « runtime/bin/io_sources.gypi ('k') | runtime/bin/native_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698