What is the closest to ConcurrentHashMap and NavigableMap in Java?

ilya-stromberg ilya-stromberg-2009 at yandex.ru
Thu Nov 14 12:57:24 PST 2013


On Thursday, 14 November 2013 at 20:00:10 UTC, Jacek 
Furmankiewicz wrote:
> I looked at the dcollections docs, but none of their 
> collections seem thread safe. The vibe.d I guess is because it 
> is meant to be used from async I/O in a single thread...but 
> once you add multi-threading to an app I am guessing it would 
> not be usable.

No, you can:
1) Use different hashmap per tread. I don't know your situation, 
but it can be possible fo read-only cache like this:

import vibe.utils.hashmap;

HashMap!(int, int) map;

void foo()
{
    //use map
    map[1] = 1;
}

2) Use `shared` storage class and mutex like this:

import vibe.utils.hashmap;

shared HashMap!(int, int) map;

void foo()
{
    synchronized
    {
       //use map
       map[1] = 1;
    }
}


More information about the Digitalmars-d-learn mailing list