dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.31k stars 1.59k forks source link

request a series API for message routing #15249

Closed DartBot closed 6 years ago

DartBot commented 11 years ago

This issue was originally filed by @stevehsu77


isolate communication is using port to pass messages between isolates. and many programmer want to use isolate more convenient as dynamic modules. but to define and control a protocol for isolates is not so easy.

propose an idea to complete with those. and then treat every isolate as a dynamic module using spwanUri();

isolates <- [router] -> isolates [router] support follows:

  1. recognize message
  2. match route rule [match user-defined properties in message]
  3. check condition [check router status/check message properties]
  4. do execution [change router status/translate message/send message]

when i implement this. i found some problems.

  1. regexp cannot support pre-compile like as c#?
  2. rule for check and do could be generated from string(dart script)
  3. translate message need to check each properties using recursive is to slow.(if vm can support object-to-object clone by rule. or map-to-map clone by rule. rule definition look like this "targetobject.a.b.c=sourceobject.a.b.c" or "targetmap['a']['b']['c']=sourceobject.a.b.c"

the best way is vm provide an router to process this. it can support function call like this ================================================================================= void setRule(String<or>FieldMirror message_type_field_name,String<or>Regexp message_type_match_regex,[String<or>SendPort source_port,bool condition(Context)<or>Stringclosure script,Result execution(Context)<or>Stringclosure script)

void unsetRule(String<or>FieldMirror message_type_field_name,String<or>Regexp message_type_match_regex)

void attachIsolate(Isolate<or>SendPort child_port) void detachIsolate(Isolate<or>SendPort child_port)

map routestatus   and then provide bool postMessage(msg) in isolate. return true if isolate is attached to router ================================================================================

i think message router is needed indeed for isolate communication.

reference: a concept for message routing https://docs.google.com/file/d/0B0J6sI4o73kvNklPTlJqbV9TaHc/edit second try to implement the architecture https://github.com/yuner/surebet first try to implement the architecture https://github.com/yunist/yun

a-siva commented 11 years ago

Not sure why this is marked as a dartium bug, it seems like a more generic Dart library feature request.


Removed Area-Dartium label. Added Area-Library label.

DartBot commented 11 years ago

This comment was originally written by @stevehsu77


Sorry about that, it should be the request for not only library but also vm core. i don't know where to post it, would you please move this issue to right please, thanks.

lrhn commented 10 years ago

Removed Type-Defect label. Added Type-Enhancement, Library-Isolate labels.