registerPortWithName method

bool registerPortWithName (SendPort port, String name)

Registers a SendPort with a given name.

Returns true if registration is successful, and false if the name entry already existed (in which case the earlier registration is left unchanged). To remove a registration, consider removePortNameMapping.

Once a port has been registered with a name, it can be obtained from any Isolate using lookupPortByName.

Multiple isolates should avoid attempting to register ports with the same name, as there is an inherent race condition in doing so.

The port and name arguments must not be null.

Implementation

static bool registerPortWithName(SendPort port, String name) {
  assert(port != null, "'port' cannot be null.");
  assert(name != null, "'name' cannot be null.");
  return _registerPortWithName(port, name);
}