Skip to main content

Crate rsynko_session

Crate rsynko_session 

Source
Expand description

§rsynko-session

rsynko-session states the relation between what is intended and what is happening. A collection states that a request wants work done; the world holds runs — threads, processes, anything this program cannot reach into. Attendance is the reconciliation of the two, and it is the same reconciliation whether the run downloads a resource, transfers a folder, or reads what a source offers.

Attendance is not recorded twice. A request that has a run is no longer one that wants a run, so what the requests themselves state is the whole record of what is running.

§Specification surface

An interpreter states five sorts through SessionSorts — the request identity, the run, what a run says, how it ends, and how it refuses — and implements four capabilities over them:

  • UndertakingAlg states which requests want work and what beginning it is;
  • RunReadAlg states whether a run is over, what it has said since it was last read, and how it ended;
  • RunHoldAlg holds a run still, lets it go, and tells one nobody wants to end;
  • AttentionAlg states what all of that means to whoever asked, and reads back what they want now as Wanted.

Time is read through ClockAlg, so how long a run has been running is a statement about a clock the interpreter supplies. Attending carries one run together with the time it has spent running and held still.

§Attention

SessionExt::attend is one pass of attention, derived from those capabilities and stating nothing of its own beyond the order it takes them in. A program written over the same capabilities composes with it:

use alux_ext::ext;
use rsynko_session::*;

#[ext(name = ExampleSessionExt)]
impl<This> This
where
    This: UndertakingAlg + RunReadAlg + RunHoldAlg + AttentionAlg + ClockAlg,
{
    /// Attends until nothing is running and nothing is left wanting to run.
    fn example_attend_until_settled(
        &mut self,
        running: &mut Vec<Attending<This::Id, This::Run, This::Moment>>,
    ) {
        while !running.is_empty() || !self.unattended().is_empty() {
            self.attend(running);
        }
    }
}

The order that pass takes is the meaning it adds. Ending comes before beginning, so leaving never races starting. A run is seen to be over before it is read, so everything it wrote before ending is read. What it said is stated before how it ended, so nothing it said is lost to the ending that followed it. And a run nobody wants is told to end on every pass until it is over, because a run that has not begun yet cannot be told to stop.

Leaving is not a separate path: an interpreter whose Wanted answers Unwanted once the reader is leaving ends every run through the ordinary pass.

§Laws

SessionLaws::session_laws checks all of that against any interpreter, over the runs a SessionLawFixture authors, reading back what each request was told as Telling.

Macros§

ambassador_impl_AttentionAlg
A macro to be used by ambassador::Delegate to delegate AttentionAlg
ambassador_impl_ClockAlg
A macro to be used by ambassador::Delegate to delegate ClockAlg
ambassador_impl_RunHoldAlg
A macro to be used by ambassador::Delegate to delegate RunHoldAlg
ambassador_impl_RunReadAlg
A macro to be used by ambassador::Delegate to delegate RunReadAlg
ambassador_impl_UndertakingAlg
A macro to be used by ambassador::Delegate to delegate UndertakingAlg

Structs§

Attending
Denotes one run, and the time it has spent running and held still.

Enums§

Telling
Denotes one thing a request was told about the run working on its behalf.
Wanted
Denotes what a request wants of the run working on its behalf.

Traits§

AttentionAlg
Specifies what beginning, saying, running, and ending mean to whoever asked for the work.
ClockAlg
Specifies reading the passage of time.
RunHoldAlg
Specifies holding one run still, letting it go again, and ending one nobody wants.
RunReadAlg
Specifies reading one run while it happens, and ending it once it is over.
SessionExt
Derives one pass of attention from beginning, reading, holding, and ending runs.
SessionLawFixture
Supplies the runs an attendance scenario cannot author for itself.
SessionLaws
Authors the attendance laws.
SessionSorts
The sorts of running work — the type families the attendance classes share.
UndertakingAlg
Specifies which requests want work done, and what beginning it is.