Skip to content

Commit e915b84

Browse files
committed
fixup
1 parent 6222084 commit e915b84

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

examples/compute.rs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -267,33 +267,33 @@ async fn local() -> anyhow::Result<()> {
267267
let api = ComputeActor::local();
268268

269269
// Test Sqr
270-
let request = api.sqr(5).await?;
271-
println!("Local: 5^2 = {}", request.await?);
270+
let rx = api.sqr(5).await?;
271+
println!("Local: 5^2 = {}", rx.await?);
272272

273273
// Test Sum
274-
let (reply, request) = api.sum().await?;
275-
reply.send(1).await?;
276-
reply.send(2).await?;
277-
reply.send(3).await?;
278-
drop(reply);
279-
println!("Local: sum of [1, 2, 3] = {}", request.await?);
274+
let (tx, rx) = api.sum().await?;
275+
tx.send(1).await?;
276+
tx.send(2).await?;
277+
tx.send(3).await?;
278+
drop(tx);
279+
println!("Local: sum of [1, 2, 3] = {}", rx.await?);
280280

281281
// Test Fibonacci
282-
let mut request = api.fibonacci(10).await?;
282+
let mut rx = api.fibonacci(10).await?;
283283
print!("Local: Fibonacci up to 10 = ");
284-
while let Some(num) = request.recv().await? {
284+
while let Some(num) = rx.recv().await? {
285285
print!("{} ", num);
286286
}
287287
println!();
288288

289289
// Test Multiply
290-
let (in_reply, mut out_request) = api.multiply(3).await?;
291-
in_reply.send(2).await?;
292-
in_reply.send(4).await?;
293-
in_reply.send(6).await?;
294-
drop(in_reply);
290+
let (in_tx, mut out_rx) = api.multiply(3).await?;
291+
in_tx.send(2).await?;
292+
in_tx.send(4).await?;
293+
in_tx.send(6).await?;
294+
drop(in_tx);
295295
print!("Local: 3 * [2, 4, 6] = ");
296-
while let Some(num) = out_request.recv().await? {
296+
while let Some(num) = out_rx.recv().await? {
297297
print!("{} ", num);
298298
}
299299
println!();
@@ -318,33 +318,33 @@ async fn remote() -> anyhow::Result<()> {
318318
let (api, handle) = remote_api()?;
319319

320320
// Test Sqr
321-
let request = api.sqr(4).await?;
322-
println!("Remote: 4^2 = {}", request.await?);
321+
let rx = api.sqr(4).await?;
322+
println!("Remote: 4^2 = {}", rx.await?);
323323

324324
// Test Sum
325-
let (reply, request) = api.sum().await?;
326-
reply.send(4).await?;
327-
reply.send(5).await?;
328-
reply.send(6).await?;
329-
drop(reply);
330-
println!("Remote: sum of [4, 5, 6] = {}", request.await?);
325+
let (tx, rx) = api.sum().await?;
326+
tx.send(4).await?;
327+
tx.send(5).await?;
328+
tx.send(6).await?;
329+
drop(tx);
330+
println!("Remote: sum of [4, 5, 6] = {}", rx.await?);
331331

332332
// Test Fibonacci
333-
let mut request = api.fibonacci(20).await?;
333+
let mut rx = api.fibonacci(20).await?;
334334
print!("Remote: Fibonacci up to 20 = ");
335-
while let Some(num) = request.recv().await? {
335+
while let Some(num) = rx.recv().await? {
336336
print!("{} ", num);
337337
}
338338
println!();
339339

340340
// Test Multiply
341-
let (in_reply, mut out_request) = api.multiply(5).await?;
342-
in_reply.send(1).await?;
343-
in_reply.send(2).await?;
344-
in_reply.send(3).await?;
345-
drop(in_reply);
341+
let (in_tx, mut out_rx) = api.multiply(5).await?;
342+
in_tx.send(1).await?;
343+
in_tx.send(2).await?;
344+
in_tx.send(3).await?;
345+
drop(in_tx);
346346
print!("Remote: 5 * [1, 2, 3] = ");
347-
while let Some(num) = out_request.recv().await? {
347+
while let Some(num) = out_rx.recv().await? {
348348
print!("{} ", num);
349349
}
350350
println!();
@@ -433,12 +433,12 @@ fn clear_line() -> io::Result<()> {
433433
// Simple benchmark sending oneshot senders via an mpsc channel
434434
pub async fn reference_bench(n: u64) -> anyhow::Result<()> {
435435
// Create an mpsc channel to send oneshot senders
436-
let (reply, mut request) = tokio::sync::mpsc::channel::<tokio::sync::oneshot::Sender<u64>>(32);
436+
let (tx, mut rx) = tokio::sync::mpsc::channel::<tokio::sync::oneshot::Sender<u64>>(32);
437437

438438
// Spawn a task to respond to all oneshot senders
439439
tokio::spawn(async move {
440-
while let Some(sender) = request.recv().await {
441-
// Immediately send a fixed reply (42) back through the oneshot sender
440+
while let Some(sender) = rx.recv().await {
441+
// Immediately send a fixed response (42) back through the oneshot sender
442442
sender.send(42).ok();
443443
}
444444
Ok::<(), io::Error>(())
@@ -450,15 +450,15 @@ pub async fn reference_bench(n: u64) -> anyhow::Result<()> {
450450
let t0 = std::time::Instant::now();
451451
for i in 0..n {
452452
let (send, recv) = tokio::sync::oneshot::channel();
453-
reply.send(send).await?;
453+
tx.send(send).await?;
454454
sum += recv.await?;
455455
if i % 10000 == 0 {
456456
print!(".");
457457
io::stdout().flush()?;
458458
}
459459
}
460460
let rps = ((n as f64) / t0.elapsed().as_secs_f64()).round() as u64;
461-
assert_eq!(sum, 42 * n); // Each reply is 42
461+
assert_eq!(sum, 42 * n); // Each response is 42
462462
clear_line()?;
463463
println!("Reference seq {} rps", rps.separate_with_underscores());
464464
}
@@ -468,13 +468,13 @@ pub async fn reference_bench(n: u64) -> anyhow::Result<()> {
468468
let t0 = std::time::Instant::now();
469469
let reqs = n0_future::stream::iter((0..n).map(|_| async {
470470
let (send, recv) = tokio::sync::oneshot::channel();
471-
reply.send(send).await?;
471+
tx.send(send).await?;
472472
anyhow::Ok(recv.await?)
473473
}));
474474
let resp: Vec<_> = reqs.buffered_unordered(32).try_collect().await?;
475475
let sum = resp.into_iter().sum::<u64>();
476476
let rps = ((n as f64) / t0.elapsed().as_secs_f64()).round() as u64;
477-
assert_eq!(sum, 42 * n); // Each reply is 42
477+
assert_eq!(sum, 42 * n); // Each response is 42
478478
clear_line()?;
479479
println!("Reference par {} rps", rps.separate_with_underscores());
480480
}

0 commit comments

Comments
 (0)