-
-
Save Restioson/d466c83ec3229baa74c86951da103926 to your computer and use it in GitHub Desktop.
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
#![feature(prelude_import)] | |
#[prelude_import] | |
use std::prelude::rust_2021::*; | |
#[macro_use] | |
extern crate std; | |
use futures::executor::block_on; | |
use xtra::prelude::*; | |
use lazy_static::lazy_static; | |
struct ActorB { | |
addr: ::spaad::export::xtra::Address<__ActorBActor::ActorB>, | |
} | |
impl Clone for ActorB { | |
fn clone(&self) -> Self { | |
Self { | |
addr: self.addr.clone(), | |
} | |
} | |
} | |
impl ActorB { | |
fn address(&self) -> &::spaad::export::xtra::Address<__ActorBActor::ActorB> { | |
&self.addr | |
} | |
fn into_address(self) -> ::spaad::export::xtra::Address<__ActorBActor::ActorB> { | |
self.addr | |
} | |
} | |
impl Into<::spaad::export::xtra::Address<__ActorBActor::ActorB>> for ActorB { | |
fn into(self) -> ::spaad::export::xtra::Address<__ActorBActor::ActorB> { | |
self.addr | |
} | |
} | |
impl From<::spaad::export::xtra::Address<__ActorBActor::ActorB>> for ActorB { | |
fn from(addr: ::spaad::export::xtra::Address<__ActorBActor::ActorB>) -> Self { | |
Self { addr } | |
} | |
} | |
#[doc(hidden)] | |
#[allow(non_snake_case)] | |
mod __ActorBActor { | |
use super::*; | |
pub struct ActorB {} | |
} | |
impl Actor for __ActorBActor::ActorB {} | |
impl ActorB { | |
pub fn new<ActorSpawner: ::spaad::export::xtra::spawn::Spawner>( | |
actor_spawner: &mut ActorSpawner, | |
) -> Self { | |
use ::spaad::export::xtra::prelude::*; | |
let act = __ActorBActor::ActorB::new(); | |
let addr = act.create(::std::option::Option::None).spawn(actor_spawner); | |
ActorB { addr } | |
} | |
#[allow(unused_mut)] | |
pub fn get_info(&self) -> impl std::future::Future<Output = usize> { | |
use ::spaad::export::xtra::prelude::*; | |
struct Msg {}; | |
impl ::spaad::export::xtra::Message for Msg { | |
type Result = usize; | |
} | |
#[allow(unused_variables)] | |
impl ::spaad::export::xtra::Handler<Msg> for __ActorBActor::ActorB { | |
#[allow( | |
clippy::let_unit_value, | |
clippy::type_complexity, | |
clippy::type_repetition_in_bounds, | |
clippy::used_underscore_binding | |
)] | |
fn handle<'life0, 'life1, 'async_trait>( | |
&'life0 mut self, | |
m: Msg, | |
ctx: &'life1 mut ::spaad::export::xtra::Context<Self>, | |
) -> ::core::pin::Pin< | |
Box< | |
dyn ::core::future::Future<Output = usize> | |
+ ::core::marker::Send | |
+ 'async_trait, | |
>, | |
> | |
where | |
'life0: 'async_trait, | |
'life1: 'async_trait, | |
Self: 'async_trait, | |
{ | |
Box::pin(async move { | |
if let ::core::option::Option::Some(__ret) = | |
::core::option::Option::None::<usize> | |
{ | |
return __ret; | |
} | |
let mut __self = self; | |
let m = m; | |
let ctx = ctx; | |
let __ret: usize = { | |
let Msg {} = m; | |
__self.get_info() | |
}; | |
#[allow(unreachable_code)] | |
__ret | |
}) | |
} | |
} | |
let f = self.addr.send(Msg {}); | |
async { f.await.expect("actor disconnected") } | |
} | |
} | |
const _: () = { | |
#[allow(unused_imports)] | |
use __ActorBActor::ActorB; | |
impl __ActorBActor::ActorB { | |
pub fn new() -> Self { | |
Self {} | |
} | |
pub fn get_info(&self) -> usize { | |
137 | |
} | |
} | |
}; | |
struct ActorA { | |
addr: ::spaad::export::xtra::Address<__ActorAActor::ActorA>, | |
} | |
impl Clone for ActorA { | |
fn clone(&self) -> Self { | |
Self { | |
addr: self.addr.clone(), | |
} | |
} | |
} | |
impl ActorA { | |
fn address(&self) -> &::spaad::export::xtra::Address<__ActorAActor::ActorA> { | |
&self.addr | |
} | |
fn into_address(self) -> ::spaad::export::xtra::Address<__ActorAActor::ActorA> { | |
self.addr | |
} | |
} | |
impl Into<::spaad::export::xtra::Address<__ActorAActor::ActorA>> for ActorA { | |
fn into(self) -> ::spaad::export::xtra::Address<__ActorAActor::ActorA> { | |
self.addr | |
} | |
} | |
impl From<::spaad::export::xtra::Address<__ActorAActor::ActorA>> for ActorA { | |
fn from(addr: ::spaad::export::xtra::Address<__ActorAActor::ActorA>) -> Self { | |
Self { addr } | |
} | |
} | |
#[doc(hidden)] | |
#[allow(non_snake_case)] | |
mod __ActorAActor { | |
use super::*; | |
pub struct ActorA { | |
pub(super) info: usize, | |
} | |
} | |
impl Actor for __ActorAActor::ActorA {} | |
impl ActorA { | |
pub fn new<ActorSpawner: ::spaad::export::xtra::spawn::Spawner>( | |
actor_spawner: &mut ActorSpawner, | |
) -> Self { | |
use ::spaad::export::xtra::prelude::*; | |
let act = __ActorAActor::ActorA::new(); | |
let addr = act.create(::std::option::Option::None).spawn(actor_spawner); | |
ActorA { addr } | |
} | |
#[allow(unused_mut)] | |
pub fn do_something(&self) -> impl std::future::Future<Output = ()> { | |
use ::spaad::export::xtra::prelude::*; | |
struct Msg {}; | |
impl ::spaad::export::xtra::Message for Msg { | |
type Result = (); | |
} | |
#[allow(unused_variables)] | |
impl ::spaad::export::xtra::Handler<Msg> for __ActorAActor::ActorA { | |
#[allow( | |
clippy::let_unit_value, | |
clippy::type_complexity, | |
clippy::type_repetition_in_bounds, | |
clippy::used_underscore_binding | |
)] | |
fn handle<'life0, 'life1, 'async_trait>( | |
&'life0 mut self, | |
m: Msg, | |
ctx: &'life1 mut ::spaad::export::xtra::Context<Self>, | |
) -> ::core::pin::Pin< | |
Box<dyn ::core::future::Future<Output = ()> + ::core::marker::Send + 'async_trait>, | |
> | |
where | |
'life0: 'async_trait, | |
'life1: 'async_trait, | |
Self: 'async_trait, | |
{ | |
Box::pin(async move { | |
if let ::core::option::Option::Some(__ret) = ::core::option::Option::None::<()> | |
{ | |
return __ret; | |
} | |
let mut __self = self; | |
let m = m; | |
let ctx = ctx; | |
let __ret: () = { | |
let Msg {} = m; | |
__self.do_something() | |
}; | |
#[allow(unreachable_code)] | |
__ret | |
}) | |
} | |
} | |
let f = self.addr.send(Msg {}); | |
async { f.await.expect("actor disconnected") } | |
} | |
} | |
const _: () = { | |
#[allow(unused_imports)] | |
use __ActorAActor::ActorA; | |
impl __ActorAActor::ActorA { | |
pub fn new() -> Self { | |
let info = block_on(ACTOR_B.get_info()); | |
{ | |
::std::io::_print(::core::fmt::Arguments::new_v1( | |
&["Got info: ", "\n"], | |
&match (&info,) { | |
(arg0,) => [::core::fmt::ArgumentV1::new( | |
arg0, | |
::core::fmt::Display::fmt, | |
)], | |
}, | |
)); | |
}; | |
Self { info } | |
} | |
pub fn do_something(&self) { | |
{ | |
::std::io::_print(::core::fmt::Arguments::new_v1( | |
&["ActorA doing something\n"], | |
&match () { | |
() => [], | |
}, | |
)); | |
}; | |
} | |
} | |
}; | |
#[allow(missing_copy_implementations)] | |
#[allow(non_camel_case_types)] | |
#[allow(dead_code)] | |
struct ACTOR_A { | |
__private_field: (), | |
} | |
#[doc(hidden)] | |
static ACTOR_A: ACTOR_A = ACTOR_A { | |
__private_field: (), | |
}; | |
impl ::lazy_static::__Deref for ACTOR_A { | |
type Target = ActorA; | |
fn deref(&self) -> &ActorA { | |
#[inline(always)] | |
fn __static_ref_initialize() -> ActorA { | |
{ | |
ActorA::new(&mut xtra::spawn::Tokio::Global) | |
} | |
} | |
#[inline(always)] | |
fn __stability() -> &'static ActorA { | |
static LAZY: ::lazy_static::lazy::Lazy<ActorA> = ::lazy_static::lazy::Lazy::INIT; | |
LAZY.get(__static_ref_initialize) | |
} | |
__stability() | |
} | |
} | |
impl ::lazy_static::LazyStatic for ACTOR_A { | |
fn initialize(lazy: &Self) { | |
let _ = &**lazy; | |
} | |
} | |
#[allow(missing_copy_implementations)] | |
#[allow(non_camel_case_types)] | |
#[allow(dead_code)] | |
struct ACTOR_B { | |
__private_field: (), | |
} | |
#[doc(hidden)] | |
static ACTOR_B: ACTOR_B = ACTOR_B { | |
__private_field: (), | |
}; | |
impl ::lazy_static::__Deref for ACTOR_B { | |
type Target = ActorB; | |
fn deref(&self) -> &ActorB { | |
#[inline(always)] | |
fn __static_ref_initialize() -> ActorB { | |
{ | |
ActorB::new(&mut xtra::spawn::Tokio::Global) | |
} | |
} | |
#[inline(always)] | |
fn __stability() -> &'static ActorB { | |
static LAZY: ::lazy_static::lazy::Lazy<ActorB> = ::lazy_static::lazy::Lazy::INIT; | |
LAZY.get(__static_ref_initialize) | |
} | |
__stability() | |
} | |
} | |
impl ::lazy_static::LazyStatic for ACTOR_B { | |
fn initialize(lazy: &Self) { | |
let _ = &**lazy; | |
} | |
} | |
fn main() { | |
let body = async { | |
ACTOR_A.do_something().await; | |
}; | |
#[allow(clippy::expect_used)] | |
tokio::runtime::Builder::new_multi_thread() | |
.enable_all() | |
.build() | |
.expect("Failed building the Runtime") | |
.block_on(body); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment