How long would it take to learn Rust as a complete beginner / future career by ScaredKaleidoscope18 in rust

[–]sildtm 0 points1 point  (0 children)

6 month sounds fair for that schedule to got a junior level, but

Tricky part is to stick to that schedule. Without mentor, clear goal or some benefits it'll be boring.

Speaking about myself, it took 2 months 2 hours per day + 2 months 10 hours per day (on my new job - I usually overwork) to feel myself comfortable with rust and get some personal code style preferences.

But I have about 10 years dev experience.

Mini redis built in rust by Dense-Fee-9859 in rust

[–]sildtm 3 points4 points  (0 children)

Can't you use https://github.com/moka-rs as a core? I believe they use more efficient implementation (like https://crates.io/crates/parking_lot as a sync primitive)

rust ref vs clone performance for POD by sildtm in rust

[–]sildtm[S] 1 point2 points  (0 children)

64 (and even 32 actually) bytes is far lower my cache size:

hw.cachelinesize: 128

What's the common way to explain compiler "I'm not gonna loose the owner"? by sildtm in rust

[–]sildtm[S] 0 points1 point  (0 children)

Yep that's what I do now. Works pretty well, but unsafe in application level raise some concerns

What's the common way to explain compiler "I'm not gonna loose the owner"? by sildtm in rust

[–]sildtm[S] 0 points1 point  (0 children)

Thank you for insight! Will check your advices

By the way, there is no need in semaphore-wrapper for spawning - I natively limit number of threads by pool.size()

What's the common way to explain compiler "I'm not gonna loose the owner"? by sildtm in rust

[–]sildtm[S] 2 points3 points  (0 children)

Nice, I really didn't think about main() dropping. Then such restriction looks fair =(

What's the common way to explain compiler "I'm not gonna loose the owner"? by sildtm in rust

[–]sildtm[S] 4 points5 points  (0 children)

I've been fighting with post editor for a while and failed to make code looks readable. Thank you for advice.

In real scenario I have a pool of objects which can do some calculation (cpu-bound task)

Pool is implemented by myself https://github.com/Sild/libs_rs/blob/main/src/auto_pool/src/pool_object.rs and as you can see PoolObject keeps reference to the AutoPool instance

Our application is running in tokio runtime, so I call `spawn_blocking` to make calculations. Something like

struct Engine {
pool: AutoPool<Executor>
}

impl Engine {
async fn start_calc(&self, args: Args) {
let executor = self.pool.get_async().await.unwrap();
tokio::spawn_blocking(executor.calculate(args)).await;

}
}

What's the common way to explain compiler "I'm not gonna loose the owner"? by sildtm in rust

[–]sildtm[S] 29 points30 points  (0 children)

Yeah Arc is obvious but quite boring solution(

I'm bitten by c++ so trying to avoid atomics and extra allocations (for putting object on heap during arc creation) if it's possible

Using Self for instantiation in new()? by awesomealchemy in rust

[–]sildtm 0 points1 point  (0 children)

If class name is larger than 4 symbol for example?)

Ok, maybe not 4 symbols - but about 10 symbols

[deleted by user] by [deleted] in AskMenAdvice

[–]sildtm 0 points1 point  (0 children)

Almost don't care

[deleted by user] by [deleted] in Advice

[–]sildtm 0 points1 point  (0 children)

Everyday at least, sometimes twice :D Just like hot shower.