datablockset / blockset

The BLOCKSET application is a command line program that can store and retrieve data blocks using a content-dependent tree (CDT) hash function as a universal address of the blocks.
GNU Affero General Public License v3.0
5 stars 0 forks source link

Split the program to state machines #52

Open sergey-shandar opened 1 year ago

sergey-shandar commented 1 year ago

Currently, we use push_ireator instead of a formal state machine.

It will allow us to switch to asynchronous I/O.

According to this post, we may use async-std instead of Tokyo. To avoid dependencies, we can split the project to two parts: a library and CLI. CLI will depend on async-std.

sergey-shandar commented 1 year ago

Reading:

let buf;
let write_tasks;
loop {
  let task = read(len);
  let new_write_tasks = handle(buf);
  await write_tasks;
  write_tasks = new_write_tasks;
  buf = await task;
  if buf.is_empty() {
    break;
  }
}
write_taks = end();
await write_tasks;