Lower-case Isolate.{IMMEDIATE,BEFORE_NEXT_EVENT}.

Change-Id: I9a7071a7f6dc61b502f5aa9bc9bc2455247a7513
Reviewed-on: https://dart-review.googlesource.com/22984
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Florian Loitsch <floitsch@google.com>
This commit is contained in:
Lasse R.H. Nielsen 2017-11-24 12:44:17 +00:00 committed by commit-bot@chromium.org
parent 3b3406fea0
commit 847cf039f0
14 changed files with 46 additions and 38 deletions

View file

@ -85,6 +85,10 @@
mock varios `dart:io` objects.
* Added `Stdin.hasTerminal`.
* `dart:isolate`
* Rename `IMMEDIATE` and `BEFORE_NEXT_EVENT` on `Isolate` to `immediate` and
`beforeNextEvent`.
* `dart.math`
* Renamed `E`, `LN10`, `LN`, `LOG2E`, `LOG10E`, `PI`, `SQRT1_2` and `SQRT2`
to `e`, `ln10`, `ln`, `log2e`, `log10e`, `pi`, `sqrt1_2` and `sqrt2`.

View file

@ -222,7 +222,7 @@ abstract class ServerIsolateChannel implements ServerCommunicationChannel {
@override
void kill() {
_isolate.kill(priority: Isolate.IMMEDIATE);
_isolate.kill(priority: Isolate.immediate);
}
@override

View file

@ -184,12 +184,12 @@ class Isolate {
}
@patch
void kill({int priority: BEFORE_NEXT_EVENT}) {
void kill({int priority: beforeNextEvent}) {
controlPort.send(["kill", terminateCapability, priority]);
}
@patch
void ping(SendPort responsePort, {Object response, int priority: IMMEDIATE}) {
void ping(SendPort responsePort, {Object response, int priority: immediate}) {
var message = new List(4)
..[0] = "ping"
..[1] = responsePort

View file

@ -385,8 +385,8 @@ class _IsolateContext implements IsolateContext {
}
void handlePing(SendPort responsePort, int pingType) {
if (pingType == Isolate.IMMEDIATE ||
(pingType == Isolate.BEFORE_NEXT_EVENT && !_isExecutingEvent)) {
if (pingType == Isolate.immediate ||
(pingType == Isolate.beforeNextEvent && !_isExecutingEvent)) {
responsePort.send(null);
return;
}
@ -394,7 +394,7 @@ class _IsolateContext implements IsolateContext {
responsePort.send(null);
}
assert(pingType == Isolate.BEFORE_NEXT_EVENT);
assert(pingType == Isolate.beforeNextEvent);
if (_scheduledControlEvents == null) {
_scheduledControlEvents = new Queue();
}
@ -403,12 +403,12 @@ class _IsolateContext implements IsolateContext {
void handleKill(Capability authentification, int priority) {
if (this.terminateCapability != authentification) return;
if (priority == Isolate.IMMEDIATE ||
(priority == Isolate.BEFORE_NEXT_EVENT && !_isExecutingEvent)) {
if (priority == Isolate.immediate ||
(priority == Isolate.beforeNextEvent && !_isExecutingEvent)) {
kill();
return;
}
assert(priority == Isolate.BEFORE_NEXT_EVENT);
assert(priority == Isolate.beforeNextEvent);
if (_scheduledControlEvents == null) {
_scheduledControlEvents = new Queue();
}

View file

@ -573,7 +573,7 @@ class Isolate {
}
@patch
void kill({int priority: BEFORE_NEXT_EVENT}) {
void kill({int priority: beforeNextEvent}) {
var msg = new List(4)
..[0] = 0 // Make room for OOB message type.
..[1] = _KILL
@ -583,7 +583,7 @@ class Isolate {
}
@patch
void ping(SendPort responsePort, {Object response, int priority: IMMEDIATE}) {
void ping(SendPort responsePort, {Object response, int priority: immediate}) {
var msg = new List(5)
..[0] = 0 // Make room for OOM message type.
..[1] = _PING

View file

@ -399,8 +399,8 @@ class _IsolateContext implements IsolateContext {
}
void handlePing(SendPort responsePort, int pingType, Object response) {
if (pingType == Isolate.IMMEDIATE ||
(pingType == Isolate.BEFORE_NEXT_EVENT && !_isExecutingEvent)) {
if (pingType == Isolate.immediate ||
(pingType == Isolate.beforeNextEvent && !_isExecutingEvent)) {
responsePort.send(response);
return;
}
@ -408,7 +408,7 @@ class _IsolateContext implements IsolateContext {
responsePort.send(response);
}
assert(pingType == Isolate.BEFORE_NEXT_EVENT);
assert(pingType == Isolate.beforeNextEvent);
if (_scheduledControlEvents == null) {
_scheduledControlEvents = new Queue();
}
@ -417,12 +417,12 @@ class _IsolateContext implements IsolateContext {
void handleKill(Capability authentification, int priority) {
if (this.terminateCapability != authentification) return;
if (priority == Isolate.IMMEDIATE ||
(priority == Isolate.BEFORE_NEXT_EVENT && !_isExecutingEvent)) {
if (priority == Isolate.immediate ||
(priority == Isolate.beforeNextEvent && !_isExecutingEvent)) {
kill();
return;
}
assert(priority == Isolate.BEFORE_NEXT_EVENT);
assert(priority == Isolate.beforeNextEvent);
if (_scheduledControlEvents == null) {
_scheduledControlEvents = new Queue();
}

View file

@ -187,12 +187,12 @@ class Isolate {
}
@patch
void kill({int priority: BEFORE_NEXT_EVENT}) {
void kill({int priority: beforeNextEvent}) {
controlPort.send(["kill", terminateCapability, priority]);
}
@patch
void ping(SendPort responsePort, {Object response, int priority: IMMEDIATE}) {
void ping(SendPort responsePort, {Object response, int priority: immediate}) {
var message = new List(4)
..[0] = "ping"
..[1] = responsePort

View file

@ -67,9 +67,13 @@ class IsolateSpawnException implements Exception {
*/
class Isolate {
/** Argument to `ping` and `kill`: Ask for immediate action. */
static const int IMMEDIATE = 0;
static const int immediate = 0;
/** Deprecated. Use [immediate] instead. */
static const int IMMEDIATE = immediate;
/** Argument to `ping` and `kill`: Ask for action before the next event. */
static const int BEFORE_NEXT_EVENT = 1;
static const int beforeNextEvent = 1;
/** Deprecated. Use [beforeNextEvent] instead. */
static const int BEFORE_NEXT_EVENT = beforeNextEvent;
/**
* Control port used to send control messages to the isolate.
@ -451,18 +455,18 @@ class Isolate {
* The isolate is requested to terminate itself.
* The [priority] argument specifies when this must happen.
*
* The [priority], when provided, must be one of [IMMEDIATE] or
* [BEFORE_NEXT_EVENT] (the default).
* The [priority], when provided, must be one of [immediate] or
* [beforeNextEvent] (the default).
* The shutdown is performed at different times depending on the priority:
*
* * `IMMEDIATE`: The isolate shuts down as soon as possible.
* * `immediate`: The isolate shuts down as soon as possible.
* Control messages are handled in order, so all previously sent control
* events from this isolate will all have been processed.
* The shutdown should happen no later than if sent with
* `BEFORE_NEXT_EVENT`.
* `beforeNextEvent`.
* It may happen earlier if the system has a way to shut down cleanly
* at an earlier time, even during the execution of another event.
* * `BEFORE_NEXT_EVENT`: The shutdown is scheduled for the next time
* * `beforeNextEvent`: The shutdown is scheduled for the next time
* control returns to the event loop of the receiving isolate,
* after the current event, and any already scheduled control events,
* are completed.
@ -471,7 +475,7 @@ class Isolate {
* of the isolate identified by [controlPort],
* the kill request is ignored by the receiving isolate.
*/
external void kill({int priority: BEFORE_NEXT_EVENT});
external void kill({int priority: beforeNextEvent});
/**
* Requests that the isolate send [response] on the [responsePort].
@ -484,20 +488,20 @@ class Isolate {
* If the isolate is alive, it will eventually send `response`
* (defaulting to `null`) on the response port.
*
* The [priority] must be one of [IMMEDIATE] or [BEFORE_NEXT_EVENT].
* The [priority] must be one of [immediate] or [beforeNextEvent].
* The response is sent at different times depending on the ping type:
*
* * `IMMEDIATE`: The isolate responds as soon as it receives the
* * `immediate`: The isolate responds as soon as it receives the
* control message. This is after any previous control message
* from the same isolate has been received and processed,
* but may be during execution of another event.
* * `BEFORE_NEXT_EVENT`: The response is scheduled for the next time
* * `beforeNextEvent`: The response is scheduled for the next time
* control returns to the event loop of the receiving isolate,
* after the current event, and any already scheduled control events,
* are completed.
*/
external void ping(SendPort responsePort,
{Object response, int priority: IMMEDIATE});
{Object response, int priority: immediate});
/**
* Requests that uncaught errors of the isolate are sent back to [port].

View file

@ -26,7 +26,7 @@ void main() {
reply.handler = (v) {
result.add(v);
if (v == 2) {
isolate.kill(priority: Isolate.BEFORE_NEXT_EVENT);
isolate.kill(priority: Isolate.beforeNextEvent);
}
echoPort.send(v - 1);
};

View file

@ -8,7 +8,7 @@ import "dart:io";
void main(List<String> args) {
if (args.contains("--child")) {
new RawReceivePort(); // Hang if not killed.
Isolate.current.kill(priority: Isolate.IMMEDIATE);
Isolate.current.kill(priority: Isolate.immediate);
// No intervening call.
throw "QQQ Should not be reached";
} else {

View file

@ -18,7 +18,7 @@ isomain1(replyPort) {
var killCapability = v[1];
firstEvent = false;
var isolate = new Isolate(controlPort, terminateCapability: killCapability);
isolate.kill(priority: Isolate.IMMEDIATE);
isolate.kill(priority: Isolate.immediate);
};
replyPort.send(port.sendPort);
}

View file

@ -26,7 +26,7 @@ void main() {
reply.handler = (v) {
result.add(v);
if (v == 2) {
isolate.kill(priority: Isolate.IMMEDIATE);
isolate.kill(priority: Isolate.immediate);
}
echoPort.send(v - 1);
};

View file

@ -41,7 +41,7 @@ void main() {
isolate.resume(resume);
pingPort.close();
};
isolate.ping(pingPort.sendPort, priority: Isolate.BEFORE_NEXT_EVENT);
isolate.ping(pingPort.sendPort, priority: Isolate.beforeNextEvent);
echoPort.send(2);
echoPort.send(1);
});

View file

@ -50,9 +50,9 @@ void main() {
}
echoPort.send(3);
ping("alive", Isolate.IMMEDIATE);
ping("alive", Isolate.immediate);
echoPort.send(2);
ping("control", Isolate.BEFORE_NEXT_EVENT);
ping("control", Isolate.beforeNextEvent);
echoPort.send(1);
echoPort.send(0);
});