diff --git a/Cargo.toml b/Cargo.toml index 79af020..db37e0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["chorus_lib", "chorus_derive"] resolver = "2" [workspace.package] -version = "0.2.0" +version = "0.3.0" edition = "2021" authors = ["Shun Kashiwa "] homepage = "https://lsd-ucsc.github.io/ChoRus/" diff --git a/chorus_book/src/SUMMARY.md b/chorus_book/src/SUMMARY.md index 9f4b87e..222c1b0 100644 --- a/chorus_book/src/SUMMARY.md +++ b/chorus_book/src/SUMMARY.md @@ -12,6 +12,6 @@ - [Input and Output](./guide-input-and-output.md) - [Higher-order Choreography](./guide-higher-order-choreography.md) - [Location Polymorphism](./guide-location-polymorphism.md) - - [Colocally and Efficient Conditional](./guide-colocally.md) + - [Choreographic Enclave and Efficient Conditional](./guide-enclave.md) - [Runner](./guide-runner.md) - [Links](./links.md) diff --git a/chorus_book/src/guide-colocally.md b/chorus_book/src/guide-enclave.md similarity index 84% rename from chorus_book/src/guide-colocally.md rename to chorus_book/src/guide-enclave.md index d563bc5..2ff895c 100644 --- a/chorus_book/src/guide-colocally.md +++ b/chorus_book/src/guide-enclave.md @@ -1,6 +1,6 @@ -# colocally and Efficient Conditional +# Choreographic Enclave and Efficient Conditional -ChoRus supports the `colocally` operator to achieve efficient conditional execution. +ChoRus supports the `enclave` operator to achieve efficient conditional execution. ## Conditional with Broadcast @@ -44,7 +44,7 @@ impl Choreography for DemoChoreography { While this code correctly implements the protocol, it is inefficient. The `is_even` value is broadcasted to all locations, but Alice does not need to receive the value. Ideally, we want to send `is_even_at_bob` only to Carol and branch only on Bob and Carol. -In ChoRus, we can achieve this using the `colocally` operator. First, let us define a sub-choreography that describes the communication between Bob and Carol: +In ChoRus, we can achieve this using the `enclave` operator. First, let us define a sub-choreography that describes the communication between Bob and Carol: ```rust {{#include ./header.txt}} @@ -70,7 +70,7 @@ impl Choreography for BobCarolChoreography { } ``` -Notice that `BobCarolChoreography` only describes the behavior of Bob and Carol (see its location set `L`). `colocally` is an operator to execute a choreography only at locations that is included in the location set. In this case, if we invoke `BobCarolChoreography` with `colocally` in the main choreography, it will only be executed at Bob and Carol and not at Alice. +Notice that `BobCarolChoreography` only describes the behavior of Bob and Carol (see its location set `L`). `enclave` is an operator to execute a choreography only at locations that is included in the location set. In this case, if we invoke `BobCarolChoreography` with `enclave` in the main choreography, it will only be executed at Bob and Carol and not at Alice. ```rust {{#include ./header.txt}} @@ -105,16 +105,16 @@ impl Choreography for MainChoreography { get_random_number() }); let x_at_bob = op.comm(Alice, Bob, &x_at_alice); - op.colocally(BobCarolChoreography { + op.enclave(BobCarolChoreography { x_at_bob, }); } } ``` -## Returning Values from Colocally +## Returning Values from Enclave -Just like the `call` operator, the `colocally` operator can return a value. However, the type of the returned value must implement the `Superposition` trait. `Superposition` provides a way for ChoRus to construct a value on locations that are not specified in the `colocally` operator. +Just like the `call` operator, the `enclave` operator can return a value. However, the type of the returned value must implement the `Superposition` trait. `Superposition` provides a way for ChoRus to construct a value on locations that are not specified in the `enclave` operator. In general, `Superposition` is either a located value or a struct consisting only of located values. The `Located` struct implements the `Superposition` trait, so you can return located values without any code. If you wish to return a struct of located values, you need to derive the `Superposition` trait using the derive macro. @@ -168,7 +168,7 @@ impl Choreography for MainChoreography { let BobCarolResult { is_even_at_bob, is_even_at_carol, - } = op.colocally(BobCarolChoreography { + } = op.enclave(BobCarolChoreography { x_at_bob, }); // can access is_even_at_bob and is_even_at_carol using `locally` on Bob and Carol diff --git a/chorus_book/src/introduction.md b/chorus_book/src/introduction.md index fdc6f13..d954bf7 100644 --- a/chorus_book/src/introduction.md +++ b/chorus_book/src/introduction.md @@ -30,7 +30,7 @@ At high level, ChoRus provides the following features: - Passing located arguments to / receiving located return values from choreographies. - Location polymorphism. - Higher-order choreographies. - - Efficient conditional with the `colocally` operator. + - Efficient conditional with choreographic enclaves. - Performing end-point projection. - Pluggable message transports. - Two built-in transports: `Local` and `HTTP`. diff --git a/chorus_lib/Cargo.toml b/chorus_lib/Cargo.toml index ad36aaf..072df22 100644 --- a/chorus_lib/Cargo.toml +++ b/chorus_lib/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["choreography"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -chorus_derive = { version = "0.2.0", path = "../chorus_derive" } +chorus_derive = { version = "0.3.0", path = "../chorus_derive" } retry = "2.0.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.104" diff --git a/chorus_lib/examples/bookseller2.rs b/chorus_lib/examples/bookseller2.rs index b62c0da..8c7894a 100644 --- a/chorus_lib/examples/bookseller2.rs +++ b/chorus_lib/examples/bookseller2.rs @@ -94,7 +94,7 @@ impl, L = LocationSet!(Buyer1, Buyer2)> + return i32::MAX; }); let price_at_buyer1 = op.comm(Seller, Buyer1, &price_at_seller); - let decision_at_buyer1 = op.colocally(D::new(price_at_buyer1)); + let decision_at_buyer1 = op.enclave(D::new(price_at_buyer1)); struct GetDeliveryDateChoreography { inventory: Located, @@ -120,7 +120,7 @@ impl, L = LocationSet!(Buyer1, Buyer2)> + } } - return op.colocally(GetDeliveryDateChoreography { + return op.enclave(GetDeliveryDateChoreography { inventory: self.inventory.clone(), title_at_seller: title_at_seller.clone(), decision_at_buyer1, diff --git a/chorus_lib/examples/loc-poly.rs b/chorus_lib/examples/loc-poly.rs index b12b3af..accaadb 100644 --- a/chorus_lib/examples/loc-poly.rs +++ b/chorus_lib/examples/loc-poly.rs @@ -47,7 +47,7 @@ impl Choreography> for MainChoreography { data: v1, }); let v2 = op.locally(Bob, |un| un.unwrap(&v2) + 10); - return op.colocally(CommAndPrint { + return op.enclave(CommAndPrint { sender: Bob, receiver: Alice, data: v2, diff --git a/chorus_lib/examples/runner.rs b/chorus_lib/examples/runner.rs index e6d39ec..0692d97 100644 --- a/chorus_lib/examples/runner.rs +++ b/chorus_lib/examples/runner.rs @@ -56,7 +56,7 @@ impl Choreography for MainChoreography { let BobCarolResult { is_even_at_bob, is_even_at_carol, - } = op.colocally(BobCarolChoreography { x_at_bob }); + } = op.enclave(BobCarolChoreography { x_at_bob }); op.locally(Bob, |un| { let is_even = un.unwrap(&is_even_at_bob); assert!(is_even); diff --git a/chorus_lib/src/core.rs b/chorus_lib/src/core.rs index b6e104d..5ac5beb 100644 --- a/chorus_lib/src/core.rs +++ b/chorus_lib/src/core.rs @@ -32,7 +32,7 @@ pub trait ChoreographyLocation: Copy { pub trait Portable: Serialize + DeserializeOwned {} impl Portable for T {} -/// Represents a value that might *NOT* be located at a location. Values returned by `colocally` must satisfy this trait. +/// Represents a value that might *NOT* be located at a location. Values returned by `enclave` must satisfy this trait. /// /// In most cases, you don't need to implement this trait manually. You can derive it using `#[derive(Superposition)]` as long as all the fields consist of located values. pub trait Superposition { @@ -282,7 +282,7 @@ pub trait ChoreoOp { M: LocationSet + Subset; /// Calls a choreography on a subset of locations. - fn colocally, Index>( + fn enclave, Index>( &self, choreo: C, ) -> R @@ -475,7 +475,7 @@ where choreo.run(&op) } - fn colocally, Index>( + fn enclave, Index>( &self, choreo: C, ) -> R { @@ -584,7 +584,7 @@ impl Runner { choreo.run(&op) } - fn colocally, Index>( + fn enclave, Index>( &self, choreo: C, ) -> R { diff --git a/cspell.json b/cspell.json index d1620b9..dc647b7 100644 --- a/cspell.json +++ b/cspell.json @@ -9,7 +9,6 @@ "Choreo", "choreographies", "chrono", - "colocally", "Condvar", "Deque", "Pluggable", @@ -20,4 +19,4 @@ "unwrapper", "ureq" ] -} +} \ No newline at end of file