Created
July 14, 2020 23:57
-
-
Save bltavares/9108bee845ff7bbcdeadeab571e8c9ab to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fn main() { | |
let client = hypercore_protocol::ProtocolBuilder::initiator().connect(tcp_stream); | |
let shared_client = Arc::new(async_std::sync::RwLock::new(client)); | |
let bg_client = shared_client.clone(); | |
let bg_task = task::spawn(async move { | |
while let Ok(e) = bg_client.write().await.loop_next().await { | |
dbg!(e); | |
} | |
}); | |
let fg_task = task::spawn(async move { | |
shared_client.read().await.open(b"deadbeef".to_vec()).await; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment