Files
sdk/runtime/vm/port.h
T
turnidge@google.com ec36e02c28 Remove the partially completed code for remote IsolateMirrors and
replace it with the beginnings of a local (same isolate) IsolateMirror
implementation.

Removed old mirror tests and added two new mirror tests.

Even though mirrors.cc is part of the vm, I chose to implement most of
it using the dart embedding interface instead of our internal
interfaces because the embedding interface was more convenient.
mirrors.cc is basically all new in this CL -- don't pay any attention
to diffs for that file.

Added dart embedding functions required for the functionality in this
CL: Dart_DebugName, Dart_GetNativeInstanceFieldCount,
Dart_RootLibrary, Dart_RegisteredLibraryUrls, and Dart_LibraryName.

Extended or modified some existing dart api functions, primarily to
make them propagate error handles properly.

Added tests for new dart embedding api functionality.

Added the ability to determine if a port is local to the current isolate.

Extended NotImplementedException to accept an optional string
argument.  I wanted to give more descriptive error messages.
Review URL: https://chromiumcodereview.appspot.com//10416050

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8117 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-30 17:07:19 +00:00

88 lines
2.2 KiB
C++

// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef VM_PORT_H_
#define VM_PORT_H_
#include "include/dart_api.h"
#include "vm/allocation.h"
#include "vm/globals.h"
namespace dart {
class Isolate;
class Message;
class MessageHandler;
class Mutex;
class PortMapTestPeer;
class PortMap: public AllStatic {
public:
// Allocate a port for the provided handler and return its VM-global id.
static Dart_Port CreatePort(MessageHandler* handler);
// Indicates that a port has had a ReceivePort created for it at the
// dart language level. The port remains live until it is closed.
static void SetLive(Dart_Port id);
// Close the port with id. All pending messages will be dropped.
//
// Returns true if the port is successfully closed.
static bool ClosePort(Dart_Port id);
// Close all the ports for the provided handler.
static void ClosePorts(MessageHandler* handler);
// Enqueues the message in the port with id. Returns false if the port is not
// active any longer.
//
// Claims ownership of 'message'.
static bool PostMessage(Message* message);
// Returns whether a port is local to the current isolate.
static bool IsLocalPort(Dart_Port id);
static void InitOnce();
private:
friend class dart::PortMapTestPeer;
// Mapping between port numbers and handlers.
//
// Free entries have id == 0 and handler == NULL. Deleted entries
// have id == 0 and handler == deleted_entry_.
typedef struct {
Dart_Port port;
MessageHandler* handler;
bool live;
} Entry;
// Allocate a new unique port.
static Dart_Port AllocatePort();
static bool IsActivePort(Dart_Port id);
static bool IsLivePort(Dart_Port id);
static intptr_t FindPort(Dart_Port port);
static void Rehash(intptr_t new_capacity);
static void MaintainInvariants();
// Lock protecting access to the port map.
static Mutex* mutex_;
// Hashmap of ports.
static Entry* map_;
static MessageHandler* deleted_entry_;
static intptr_t capacity_;
static intptr_t used_;
static intptr_t deleted_;
static Dart_Port next_port_;
};
} // namespace dart
#endif // VM_PORT_H_