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

Issue 8297004: Allow embedders to provide custom message delivery for an isolate. (Closed)

Created:
9 years, 2 months ago by turnidge
Modified:
9 years, 2 months ago
Reviewers:
Anton Muhin, siva
CC:
reviews_dartlang.org, vm-dev_dartlang.org, vsm
Visibility:
Public.

Description

Allow embedders to provide custom message delivery for an isolate. ============== Added Dart_SetPostMessageCallback and Dart_SetClosePortCallback. These allow the embedder to provide custom message/port behavior for their application. The vm provides standard implementations that work with the standard run loop. Added Dart_HandleMessage, which processes one message on the current isolate. Embedders can use this to write their own message processing loops. Rewrote code to use this internally. Added Isolate::StandardRunLoop() to share code between Dart_RunLoop and lib/isolate.cc Changed the interface to PortMap::PostMessage. PostMessage is now agnostic to message delivery mechanism. Note that PortMap is now out of the "ReceiveMessage" business entirely. Moved MessageQueue and friends out to message_queue.cc/h. Moved the monitor from the Isolate into the MessageQueue. No need for outsiders to mess. Added MessageQueue::Wait. Moved monitor locking from PortMap into MessageQueue itself, which was easier for me to reason about. Wrote some tests. Removed PortMessage::Handle. The code turned into Dart_HandleMessage. Regularized the nomenclature around ports. Type is now always Dart_Port instead of intptr_t. Variables end in _port instead of _id. Use the term "dest" instead of "target" or "send". Added a family of new tests to port_test. Added EXPECT_NE to the test framework. Committed: https://code.google.com/p/dart/source/detail?r=516

Patch Set 1 #

Total comments: 42

Patch Set 2 : '' #

Total comments: 33

Patch Set 3 : '' #

Total comments: 24

Patch Set 4 : '' #

Patch Set 5 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+688 lines, -727 lines) Patch
M runtime/include/dart_api.h View 1 2 3 4 2 chunks +67 lines, -6 lines 0 comments Download
M runtime/lib/isolate.cc View 1 2 3 4 chunks +3 lines, -55 lines 0 comments Download
M runtime/vm/assert.h View 1 2 3 3 chunks +17 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_impl.cc View 1 2 3 4 chunks +78 lines, -15 lines 0 comments Download
M runtime/vm/dart_api_impl_test.cc View 1 2 3 1 chunk +23 lines, -0 lines 0 comments Download
M runtime/vm/isolate.h View 1 2 3 3 chunks +17 lines, -2 lines 0 comments Download
M runtime/vm/isolate.cc View 1 2 3 7 chunks +49 lines, -11 lines 0 comments Download
A + runtime/vm/message_queue.h View 1 2 chunks +23 lines, -78 lines 0 comments Download
A + runtime/vm/message_queue.cc View 1 2 5 chunks +20 lines, -234 lines 0 comments Download
A + runtime/vm/message_queue_test.cc View 1 1 chunk +179 lines, -87 lines 0 comments Download
M runtime/vm/port.h View 1 2 3 3 chunks +17 lines, -68 lines 0 comments Download
M runtime/vm/port.cc View 1 2 3 10 chunks +52 lines, -131 lines 0 comments Download
M runtime/vm/port_test.cc View 1 2 3 3 chunks +140 lines, -40 lines 0 comments Download
M runtime/vm/vm_sources.gypi View 1 2 3 1 chunk +3 lines, -0 lines 0 comments Download

Messages

Total messages: 11 (0 generated)
turnidge
Okay, here's the review on the correct branch...
9 years, 2 months ago (2011-10-14 18:44:01 UTC) #1
siva
LGTM with some comments. http://codereview.chromium.org/8297004/diff/1/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8297004/diff/1/runtime/include/dart_api.h#newcode85 runtime/include/dart_api.h:85: // and when spawning new ...
9 years, 2 months ago (2011-10-14 21:01:52 UTC) #2
turnidge
Please take another look. http://codereview.chromium.org/8297004/diff/1/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8297004/diff/1/runtime/include/dart_api.h#newcode85 runtime/include/dart_api.h:85: // and when spawning new ...
9 years, 2 months ago (2011-10-14 23:08:02 UTC) #3
siva
LGTM http://codereview.chromium.org/8297004/diff/7001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8297004/diff/7001/runtime/include/dart_api.h#newcode197 runtime/include/dart_api.h:197: // A convenience routine for which processes any ...
9 years, 2 months ago (2011-10-14 23:50:32 UTC) #4
Anton Muhin
Sorry for late response, was OOO. http://codereview.chromium.org/8297004/diff/7001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8297004/diff/7001/runtime/include/dart_api.h#newcode208 runtime/include/dart_api.h:208: // delivery mechanism ...
9 years, 2 months ago (2011-10-17 15:20:29 UTC) #5
turnidge
PTAL http://codereview.chromium.org/8297004/diff/7001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8297004/diff/7001/runtime/include/dart_api.h#newcode197 runtime/include/dart_api.h:197: // A convenience routine for which processes any ...
9 years, 2 months ago (2011-10-17 18:38:48 UTC) #6
Anton Muhin
Todd, it looks like you haven't uploaded a new version of patch. http://codereview.chromium.org/8297004/diff/7001/runtime/include/dart_api.h File runtime/include/dart_api.h ...
9 years, 2 months ago (2011-10-18 07:01:03 UTC) #7
turnidge
Sorry, forgot to upload. Uploading now... http://codereview.chromium.org/8297004/diff/7001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8297004/diff/7001/runtime/include/dart_api.h#newcode197 runtime/include/dart_api.h:197: // A convenience ...
9 years, 2 months ago (2011-10-18 16:42:14 UTC) #8
Anton Muhin
http://codereview.chromium.org/8297004/diff/15001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8297004/diff/15001/runtime/include/dart_api.h#newcode205 runtime/include/dart_api.h:205: // Messages/ports nit: missing trailing dot I believe. http://codereview.chromium.org/8297004/diff/15001/runtime/include/dart_api.h#newcode207 ...
9 years, 2 months ago (2011-10-18 17:19:58 UTC) #9
turnidge
http://codereview.chromium.org/8297004/diff/15001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8297004/diff/15001/runtime/include/dart_api.h#newcode205 runtime/include/dart_api.h:205: // Messages/ports On 2011/10/18 17:19:58, antonmuhin wrote: > nit: ...
9 years, 2 months ago (2011-10-18 17:33:40 UTC) #10
Anton Muhin
9 years, 2 months ago (2011-10-18 17:40:53 UTC) #11
LGTM too.

http://codereview.chromium.org/8297004/diff/15001/runtime/include/dart_api.h
File runtime/include/dart_api.h (right):

http://codereview.chromium.org/8297004/diff/15001/runtime/include/dart_api.h#...
runtime/include/dart_api.h:220: typedef bool
(*Dart_PostMessageCallback)(Dart_Isolate dest_isolate,
Great.  Minor correction: not posted, but something like queued or processed.

On 2011/10/18 17:33:40, turnidge wrote:
> On 2011/10/18 17:19:58, antonmuhin wrote:
> > what's the semantics of returned value?
> 
> Added:
> 
> // The callback should return true if the message was successfully
> // posted.

http://codereview.chromium.org/8297004/diff/15001/runtime/vm/message_queue.cc
File runtime/vm/message_queue.cc (right):

http://codereview.chromium.org/8297004/diff/15001/runtime/vm/message_queue.cc...
runtime/vm/message_queue.cc:43: if (result == NULL) {
On 2011/10/18 17:33:40, turnidge wrote:
> On 2011/10/18 17:19:58, antonmuhin wrote:
> > should it be if or while?  Wait is usually in the loop, but you might have
> > stronger guarantees (but I would keep it in the loop anyway).
> 
> This should be an 'if'.  The loop is in the caller.

Oh, I see, thanks.

Powered by Google App Engine
This is Rietveld 408576698