aboutsummaryrefslogtreecommitdiff
path: root/examples/std/src/bin/tcp_accept.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-05-31 23:49:00 +0000
committerGitHub <[email protected]>2023-05-31 23:49:00 +0000
commitc036eab62c2221bd8f458bd6edd1562dfcdb8421 (patch)
tree605b3eb96ea10120f7e8bf0741bcc34daab8e9ec /examples/std/src/bin/tcp_accept.rs
parentd7d66bd74f2ef1bc8903b15df630ddbb8fe97df4 (diff)
parent1d8321b821d114b369d5a087a1a7a6600228b032 (diff)
Merge pull request #1523 from embassy-rs/static-cell
Use make_static! from static-cell v1.1
Diffstat (limited to 'examples/std/src/bin/tcp_accept.rs')
-rw-r--r--examples/std/src/bin/tcp_accept.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/examples/std/src/bin/tcp_accept.rs b/examples/std/src/bin/tcp_accept.rs
index 97ce77f42..d24e218dc 100644
--- a/examples/std/src/bin/tcp_accept.rs
+++ b/examples/std/src/bin/tcp_accept.rs
@@ -12,21 +12,12 @@ use embedded_io::asynch::Write as _;
12use heapless::Vec; 12use heapless::Vec;
13use log::*; 13use log::*;
14use rand_core::{OsRng, RngCore}; 14use rand_core::{OsRng, RngCore};
15use static_cell::StaticCell; 15use static_cell::{make_static, StaticCell};
16 16
17#[path = "../tuntap.rs"] 17#[path = "../tuntap.rs"]
18mod tuntap; 18mod tuntap;
19 19
20use crate::tuntap::TunTapDevice; 20use crate::tuntap::TunTapDevice;
21
22macro_rules! singleton {
23 ($val:expr) => {{
24 type T = impl Sized;
25 static STATIC_CELL: StaticCell<T> = StaticCell::new();
26 STATIC_CELL.init_with(move || $val)
27 }};
28}
29
30#[derive(Parser)] 21#[derive(Parser)]
31#[clap(version = "1.0")] 22#[clap(version = "1.0")]
32struct Opts { 23struct Opts {
@@ -77,7 +68,12 @@ async fn main_task(spawner: Spawner) {
77 let seed = u64::from_le_bytes(seed); 68 let seed = u64::from_le_bytes(seed);
78 69
79 // Init network stack 70 // Init network stack
80 let stack = &*singleton!(Stack::new(device, config, singleton!(StackResources::<3>::new()), seed)); 71 let stack = &*make_static!(Stack::new(
72 device,
73 config,
74 make_static!(StackResources::<3>::new()),
75 seed
76 ));
81 77
82 // Launch network task 78 // Launch network task
83 spawner.spawn(net_task(stack)).unwrap(); 79 spawner.spawn(net_task(stack)).unwrap();