crossbeam icon indicating copy to clipboard operation
crossbeam copied to clipboard

i need use an Map struct,Which one should I use?

Open zhuxiujia opened this issue 4 years ago • 7 comments

i need use an Map struct,Which one should I use。 the Map struct must impl Sync and Send,and do not use '&mut self' just like SegQueue

zhuxiujia avatar Jun 17 '20 14:06 zhuxiujia

Crossbeam does not provide this but I happen to do research on this stuff. There are a few libraries available. I've devised benchmarks for all good ones I could gather here. So run the benchmarks and pick whichever you fancy from the list in the readme.

xacrimon avatar Jun 21 '20 19:06 xacrimon

Crossbeam does not provide this but I happen to do research on this stuff. There are a few libraries available. I've devised benchmarks for all good ones I could gather here. So run the benchmarks and pick whichever you fancy from the list in the readme.

These libraries enforce the use of custom drops. if crossbeam can support SyncMap just like golang's SyncMap . Even if write is locked, read is unlocked, or GC It's going to be great

zhuxiujia avatar Aug 01 '20 07:08 zhuxiujia

? I don't understand. Everything relies on cust drops. The dashmap library is as close to syncmap as you will get.

xacrimon avatar Aug 01 '20 07:08 xacrimon

? I don't understand. Everything relies on cust drops. The dashmap library is as close to syncmap as you will get.

fine thank you

zhuxiujia avatar Aug 01 '20 07:08 zhuxiujia

? I don't understand. Everything relies on cust drops. The dashmap library is as close to syncmap as you will get.

DashMap is implemented using read-write locks . my project also use of tokio(actix-web). if use RwLock it will be lock the runtime(may be lock stop all of async task). The best way to do this is to do it lock-free,just like corssbeam's lock-free Queue?

zhuxiujia avatar Aug 01 '20 15:08 zhuxiujia

if use RwLock it will be lock the runtime(may be lock stop all of async task)

You can just run this code on special tokio threadpool for blocking code.

AngelicosPhosphoros avatar Oct 17 '20 13:10 AngelicosPhosphoros

if use RwLock it will be lock the runtime(may be lock stop all of async task)

You can just run this code on special tokio threadpool for blocking code.

But it's not a good idea

zhuxiujia avatar Oct 18 '20 07:10 zhuxiujia

See https://crates.io/crates/crossbeam-skiplist for map/set in crossbeam. See crates mentioned in https://github.com/crossbeam-rs/rfcs/issues/32 for concurrent hashmap (crossbeam currently doesn't provide concurrent hashmap).

taiki-e avatar Dec 02 '23 11:12 taiki-e