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

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

Issue 12328037: Add missing files from previous commit (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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/native_service.h ('k') | sdk/lib/io/file_system_entity.dart » ('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 #include "bin/native_service.h"
6
7 #include "platform/globals.h"
8 #include "bin/thread.h"
9
10
11 NativeService::NativeService(const char* name,
12 Dart_NativeMessageHandler handler,
13 int number_of_ports)
14 : name_(name),
15 handler_(handler),
16 service_ports_size_(number_of_ports),
17 service_ports_index_(0) {
18 service_ports_ = new Dart_Port[service_ports_size_];
19 for (int i = 0; i < service_ports_size_; i++) {
20 service_ports_[i] = ILLEGAL_PORT;
21 }
22 }
23
24
25 NativeService::~NativeService() {
26 delete[] service_ports_;
27 }
28
29
30 Dart_Port NativeService::GetServicePort() {
31 MutexLocker lock(&mutex_);
32 Dart_Port result = service_ports_[service_ports_index_];
33 if (result == ILLEGAL_PORT) {
34 result = Dart_NewNativePort(name_, handler_, true);
35 ASSERT(result != ILLEGAL_PORT);
36 service_ports_[service_ports_index_] = result;
37 }
38 service_ports_index_ = (service_ports_index_ + 1) % service_ports_size_;
39 return result;
40 }
OLDNEW
« no previous file with comments | « runtime/bin/native_service.h ('k') | sdk/lib/io/file_system_entity.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698