DemesneGH commented on code in PR #120:
URL: 
https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/120#discussion_r1477278187


##########
optee-teec/Cargo.toml:
##########
@@ -30,6 +30,10 @@ optee-teec-macros = { path = "macros" }
 libc = "0.2"
 uuid = "0.7"
 hex = "0.3"
+self_cell = { version = "1.0", optional = true }
+
+[features]
+owned = ["self_cell"]

Review Comment:
   how about change the feature name to the more accurate name such as  
`owned_session`?



##########
optee-teec/src/session.rs:
##########
@@ -40,16 +44,58 @@ pub enum ConnectionMethods {
     LoginGroupApplication,
 }
 
+// Sessions are documented as threadsafe in GP. Sessions with non-static 
lifetimes
+// cannot be send because we cannot ensure that their context lives long 
enough, but
+// sessions with 'static lifetime should be Send.
+//
+// A few ways to construct a session with static lifetime:
+// 1. With the "owned" feature, use an `OwnedSession`

Review Comment:
   Can we have a `hello-world` example for multi-thread session? It would be 
great if the example can be tested on our CI



##########
optee-teec/src/context.rs:
##########
@@ -106,12 +132,37 @@ impl Context {
     /// let session = ctx.open_session_with_operation(uuid, 
operation).unwrap();
     /// ```
     pub fn open_session_with_operation<A: Param, B: Param, C: Param, D: Param>(
-        &mut self,
+        &self,
         uuid: Uuid,
         operation: &mut Operation<A, B, C, D>,
     ) -> Result<Session> {
         Session::new(self, uuid, Some(operation))
     }
+
+    #[cfg(feature = "owned")]
+    /// Opens a new owned session with the specified trusted application, pass 
some
+    /// parameters to TA by an operation.
+    ///
+    /// The target trusted application is specified by `uuid`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use std::sync::Arc;
+    /// let mut ctx = Arc::new(Context::new().unwrap());
+    /// let uuid = 
Uuid::parse_str("8abcf200-2450-11e4-abe2-0002a5d5c51b").unwrap();
+    /// let p0 = ParamValue(42, 0, ParamType::ValueInout);
+    /// let mut operation = Operation::new(0, p0, ParamNone, ParamNone, 
ParamNone);
+    /// let session = ctx.open_session_with_operation(uuid, 
operation).unwrap();

Review Comment:
   `ctx.open_session_with_operation` to `ctx.open_owned_session_with_operation`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org
For additional commands, e-mail: dev-h...@teaclave.apache.org

Reply via email to