A list of puns related to "Crossbeams"
I'm looking to find or create something like a crossbeam channel or a ring buffer that can be "cleared" from the sender side. I have this working, sorta:
let (mut s, mut r) = ClearRing::new(10);
s.send(1).unwrap();
s.send(2).unwrap();
s.send(3).unwrap();
s.clear();
s.send(4).unwrap();
assert_eq!(r.recv().unwrap(), 4);
This does seem to work (playground), but I can't think of a nice ergonomic way to use the select!
macro with it.
In my program I want to be able to do something like this, so that my threads don't deadlock each other and so they remain responsive to messages, while also not consuming a ton of CPU. Something like:
select! {
recv(items) -> item => { /* process it */ },
recv(commands) -> cmd => { /* do something */ },
recv(halt) -> msg => { /* quit */ },
}
At the moment this doesn't actually work, because select!
only works with actual crossbeam::channel::Receiver
's, not my wrapper. It seems like I'd either need to write my own Select
, or expose the channel-clearing logic to every call site. Anyone have ideas?
Hi everyone, just released the first version of SwapQueue, a highly optimized and feature-light crossbeam::deque alternative designed solely for the singular use case of taking the entire queue by buffer swapping. By giving up the ability to pop individual tasks we can make a data structure that's better suited for take-all batching. Please let me know if you see any soundness issues: I think I'm using viable atomic memory orderings and that there isn't any potential for UB, but there's quite a bit of unsafeness going on here by design.
Hey folks, my team, Crossbeam.com , is looking for a Senior Engineer - Tech Lead, to join us. While Clojure experience isn't mandatory, we love to see Clojure Engineers as it's what our product is entirely built-in (after a short stint in Python which we quickly outgrew). Job Posting linked!
We're a remote-first workforce, while we have an office in Philly of our ~18 engineers, only 8 are located in Philly, the rest spread out across the US from SanFran to FL. Unfortunately not open to folks outside the US at this time.
Before starting selecting a desk, I want to know what in general is the best construction method for a desk. What is your opinion? I see different approaches:
What looks cool but does not work (marketing) or what is cheaper to built but does not help the quality of the product?
Thanks
Hi all.
I am interested in sharing and from time to time updating a managed state in Rocket (0.5.0-rc.1) and thought that crossbeam_epoch is probably a nice way of doing this. I did an implementation using Arc<Mutex<<>> and while it works it is more verbose than this one.
I am however a bit unsure about the unsafe usage and if my understanding of the safety note is correct.
If you have the time I would love some feedback on this :)
#[macro_use]
extern crate rocket;
use crossbeam_epoch::{Atomic, Owned};
use rocket::State;
use std::sync::atomic::Ordering;
#[derive(Debug)]
struct MyState {
pub data: String,
}
#[get("/")]
fn read(state: &State<Atomic<MyState>>) -> String {
let guard = crossbeam_epoch::pin();
let my_state = state.inner().load(Ordering::Acquire, &guard);
// Safety: MyState pointer is never de allocated
let my_state = unsafe { my_state.deref() };
my_state.data.clone()
}
#[post("/", data = "<new_state>")]
fn write(new_state: String, state: &State<Atomic<MyState>>) -> String {
state.inner().store(
Owned::new(MyState {
data: new_state.clone(),
}),
Ordering::Release,
);
new_state
}
#[launch]
fn rocket() -> _ {
let state = MyState {
data: "Test".to_string(),
};
let x = Atomic::<MyState>::init(state);
rocket::build().manage(x).mount("/", routes[read, write])
}
so i am using a 4x4 piece of lumber and i'm attaching it at two ends to posts. this shape: |----| what I want to know is: how can i determine the maximum load before fracture / failure if i hang something from the middle? |--x--| I am assuming it is somehow related to material density / dimensions as well as length of the beam, but idk how the math works out. this is probably statics 101 but I spent my career in IT and not physics lol. if there's a better subreddit for this stuff, please point me there. k thanks!
Here is a picture of the corner I'm trying to replace from rot. https://imgur.com/69jcBmU This is next to the bathtub and the toliet goes here. I know I need to pull this all up and replace it with new plywood, but how do I secure the plywood and make it safe to bear weight when there isn't a beam or joist at this corner to screw it to? There's a beam maybe 8 inches under the tub, and not one for a long while under the wall. I've found good resources online, but they all assume there's a cross beam before the corner of the wall. Any help is appreciated, thanks!
This is my diagram of what is going on under the floor https://imgur.com/JS383uB This is what it looks like facing the tub https://imgur.com/tusQd5y This is what it looks like facing the wall: https://imgur.com/My9ylAX
In iconography and in many Jesus movies they show Jesus literally carrying the whole cross. But in some Jesus movies they show Jesus only carrying the crossbeam, which I guess is more realistic.
Was it the whole cross or just the crossbeam?
Hi folks! I'm a Rust noob trying to build something. For last 3-4 days I'm facing an issue with my code where the program doesn't terminate and haven't been able to understand why. Hence, posting here for help π
Basically, I'm trying to process a set of files using Channels
on a ThreadPool
created using rayon
(below is a snippet of core logic). This code doesn't seem to terminate.
I've tried multiple things with no luck. Any idea what I could be doing wrong? I might be missing something obvious here but not sure π (Code snippet is below)
Things tried:
thread::spawn
and joining those handles, didn't help.receiver.iter()
instead of receiver.recv()
and thought that would help, but didn't.receiver.try_recv()
. But, from what I understood from documentation try_recv()
doesn't wait but I would like the receiver thread to wait until sender is dropped.receiver_thread
, that doesn't work too. So, this is when I realised I'm doing some basic blunder.Also, Any tips on how can I debug this better?
FlameGraph
to visualize where it's stuck in execution, but doesn't run on Mac (dtrace: failed to initialize dtrace)Thanks in advance!
use rayon::prelude::*;
use std::collections::HashMap;
use std::sync::{mpsc, Arc, Mutex};
use std::*;
fn parallel_compute() -> Result<(), Box<dyn error::Error>> {
let (sender, receiver) = mpsc::channel();
let map: Arc<Mutex<HashMap<u32, u32>>> = Arc::new(Mutex::new(HashMap::new()));
let pool = rayon::ThreadPoolBuilder::new().build()?;
sender.send(1u32)?;
let map_clone = map.clone();
let sender_clone = sender.clone();
let reeiver_thread = thread::spawn(move || {
while let Ok(id) = receiver.recv() {
let sender_inner_clone = sender_clone.clone();
let map_inner_clone = map_clone.clone();
pool.spawn(move || {
println!("Processing {}", id);
map_i
... keep reading on reddit β‘Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.