Skip to content

Return value to original caller, sleep to imitate workload #13

Answered by uazu
TmLev asked this question in Q&A
Discussion options

You must be logged in to vote

To return a value to the caller, pass a Ret instance in the call. Then the called method can pass back a value using the ret! macro on that Ret instance. This could be later on, e.g. it could store the Ret somewhere and return a value later when some calculation has completed (or whatever). There is a brief example in the docs -- in particular the call to query: let ret = ret_some_to!([cx], recv_state(self.count) as (bool)); call!([self.light], query(ret));. The ret_to! and ret_some_to! macros do the job of creating a Ret to return the data to the caller. They can either return to a local method of the caller (may be private) or to inline code. So the Ret is like an asynchronous callback,…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@TmLev
Comment options

@uazu
Comment options

uazu Apr 19, 2021
Maintainer

@TmLev
Comment options

@uazu
Comment options

uazu Apr 20, 2021
Maintainer

Answer selected by TmLev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants