thlorenz / rid

Rust integrated Dart framework providing an easy way to build Flutter apps with Rust.
63 stars 4 forks source link

[feat] async: adding support multi threaded applications responding to messages async #3

Closed thlorenz closed 3 years ago

thlorenz commented 3 years ago

Summary

Lots of work and rethinking went into this one. Main goal was to keep things safe but allowing multiple threads to read/write to the store.

In the end I decided to provide a higher level API for devs that don't want to deal with having to lock/unlock the store when accessing state and are OK with a small perf hit due to possibly fetching/converting data parts to Dart that might not be needed. When needed they can use the lower level API which is provided as well and sits just below that higher level API

The following are the main points here to support this in a user friendly way.

Message/Reply

Multithreaded Store Access

There is lots more here, but I won't go into too much detail that is easier learned by reading the updated code.

Please consult the store docs to learn more about this new attribute.

The application doc talks here about the Message/Reply pattern.

LMK if you have any questions. I'm planning to squash+merge this soon as I'm planning to stream building this example app which uses the Message/Reply pattern and includes a multi-threaded aspect of a ticker expiring a Todo

Fixes: #2

cc @Yatekii

thlorenz commented 3 years ago

This section of the video I released today explains the locking/unlocking going on in an example.