-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
async: default function arguments, finish documenting
- Loading branch information
Showing
5 changed files
with
56 additions
and
12 deletions.
There are no files selected for viewing
13 changes: 7 additions & 6 deletions
13
doc/src/references/builtin/concurrency/classes/async/!async.nvgt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
doc/src/references/builtin/concurrency/classes/async/properties/failed.nvgt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
Returns true if an async function call has thrown an exception. | ||
const bool failed; | ||
## Remarks: | ||
This is a shorthand version of executing the expression (async.try_wait(0) and async.exception != ""), provided for syntactical ease. | ||
*/ | ||
|
||
// Example | ||
string throw_exception_randomly() { | ||
if (random_bool(50)) throw("oh no!"); | ||
return "yo yo"; | ||
} | ||
void main() { | ||
async<string> result(throw_exception_randomly); | ||
result.wait(); | ||
if (result.failed) alert("oops", result.exception); | ||
else alert("success", result.value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters