Questions tagged [crossbeam]

18 questions
4
votes
1 answer

Why does tokio::spawn have a delay when called next to crossbeam_channel::select?

I'm creating a task which will spawn other tasks. Some of them will take some time, so they cannot be awaited, but they can run in parallel: src/main.rs use crossbeam::crossbeam_channel::{bounded, select}; #[tokio::main] async fn main() { let…
Krzysiu
  • 43
  • 4
2
votes
1 answer

How to send messages to iced application

I have an iced application that I want to control through a web UI. For this I use axum and spawn it in a different tokio task. I would like to send a message from the axum endpoint to the iced application, but I can neither invoke the update method…
Daniel Schmidt
  • 11,605
  • 5
  • 38
  • 70
1
vote
0 answers

Auto-scale receiver count with crossbeam-channel in Rust

When using a multi-sender/multi-receiver channels like crossbeam-channel or async-channel, I would like to dynamically scale the number of receivers based on the channel congestion state. If there are too many pending item is the channel, more…
Yuri Astrakhan
  • 8,808
  • 6
  • 63
  • 97
1
vote
0 answers

mutate rust value between threads with crossbeam

I am modifiying a crate (rust-argon2) to some custom needs. That crate uses multithreading with scoped threads using crossbeam. I want to have a mutable state between threads, that may depend on each other. The following snippet showcases the…
prohit
  • 609
  • 1
  • 6
  • 18
1
vote
1 answer

Multi-threaded code that uses crossbeam channel and scoped threads stuck endlessly

I have the following code that is using a bounded channel with capacity (20) less than the total amount of data (32) that I want to send via a crossbeam channel. My goal is to use multiple sender threads (8) and a certain amount (4) of numbers each…
1
vote
1 answer

Crossbeam zero-capacity channel which does not block on send

I need a variant of Crossbeam's zero-capacity channel, crossbeam_channel::bounded(0), which does not block on send() if there is no receive operation. In my case, messages that are sent while there is no receive operation in progress can be…
rubik
  • 8,814
  • 9
  • 58
  • 88
0
votes
1 answer

Rust - Use threads to iterate over a vector

My program creates a grid of numbers, then based on the sum of the numbers surrounding each on the grid the number will change in a set way. I'm using two vectors currently, filling the first with random numbers, calculating the changes, then…
0
votes
1 answer

How to create threads that last entire duration of program and pass immutable chunks for threads to operate on?

I have a bunch of math that has real time constraints. My main loop will just call this function repeatedly and it will always store results into an existing buffer. However, I want to be able to spawn the threads at init time and then allow the…
0
votes
2 answers

Rust send serialized struct from crossbeam channel to multiple receivers via tcp

I am trying to send a serialized struct over tcp to multiple machines. The tcp handler receives the serialized struct (String type) by a crossbeam channel from another thread. My problem is that the rx.try_iter() will drain the crossbeam channel,…
tlhenvironment
  • 319
  • 2
  • 10
0
votes
1 answer

Multiple consumers in crossbeam example

Dear Stackoverflow community, I just started to play around with rust. To increase speed, I took a look at crossbeam: The content of the channel should be processed by several thread at the same time. On the one hand a wait condition for the threads…
user2757652
  • 353
  • 2
  • 9
0
votes
1 answer

I dont understand this lifetime error : spawining threads inside a struct function

Not much to explain. I don't understand what is even having the lifetime designated 1 and 2 by the compiler error message. All posts I have checked so far just say use crossbeam for scopped threads, but this hasn't fixed my issue at all and I dont…
user12498615
0
votes
1 answer

Borrow mutable in a loop

I try to process an array with multiple worker threads, just like Rayon's par_iter() function, but i want to have a mutable reference target, one for each thread. I have a simple function like this pub fn…
0
votes
3 answers

Mixing select! and async calls in Rust

I am building a small app that's supposed to schedule two tasks (based on rusoto AWS SDK) at different intervals: every X seconds, run one task, and every Y seconds, run the other. I found crate crossbeam that offers a tick timer and a select! macro…
Victor
  • 13,914
  • 19
  • 78
  • 147
0
votes
1 answer

How to return a struct with references in rust?

I'm using crossbeam-epoch to write a lock-free data structure in rust. crossbeam-epoch uses a guard to load the heap-allocated atomic pointer. One example of the data structure's interface is: fn get(&self, index: IndexType, guard: &'guard Guard) ->…
mmch
  • 15
  • 5
0
votes
1 answer

Changing in parallel a two-dimensional vector

I'm trying to set the value 1 at each position of a two-dimensional vector (graph) using the crossbeam_utils version 0.8.0. The sub-matrices each thread receives are disjoint. I'm running the code with cargo run on Windows. My code is based on these…
tnas
  • 510
  • 5
  • 16
1
2