An alias for `Arc<Mutex<T>>`?

Hi all. I apologize in advance if the question either has been discussed before (I couldn’t seem to google anything) or if it’s silly.

How about having a shorthand for Arc<Mutex<T>> ? The rationale is that this particular combo seems to be used very often, but is quite verbose in both definition (foo: Arc<Mutex<Foo>>) as well as creation (let foo = Arc::new(Mutex::new(Foo::new(...)))).

There could be a wrapper named Arm or Arx or similar, which could be a simple tuple struct dereferencing to the Arc.

Just an idea.

Hmmm… you can easily define such a wrapper for your personal use, or in a crate, but I am not sure if the stdlib should encourage encourage people to use shared ownership and mutexes intensively. The latter especially is quite a sharp tool, it is easy to introduce performance bottlenecks and race conditions with it.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.