Skip to main content

main

Attribute Macro main 

#[main]
Available on crate feature macros only.
Expand description

Run an async fn main on a runtime of its own.

The body becomes the future handed to Runtime::block_on, and the arguments configure what it is handed to:

  • crate = path names the crate to reach the runtime through, for a compio that is renamed or reached through another crate;
  • any other name = value becomes a RuntimeBuilder method call, as does every name = value within with_proactor(..) on the ProactorBuilder;
  • console installs console_subscriber::init() before the runtime runs. The caller needs a dependency on console-subscriber for it to be there to install, the console_without_tokio_unstable rustflag for the install not to panic on the way up, and the console feature for there to be any instrumentation for it to report on. Only the first of the three can be checked from here; see the console module for the other two.
#[compio::main(event_interval = 8, with_proactor(capacity = 1024))]
async fn main() {
    // ...
}