Skip to content

Question: thread safety of read only accesses #651

@kimwalisch

Description

@kimwalisch

Hi,

Are nlohmann::json objects thread safe for read only operations? E.g. assuming that the json object is not modified anymore after load_json(), can I safely query the json object from multiple threads as in the example below?

// single threaded
auto json = load_json();

#pragma omp parallel for
for (int i = 0; i < threads; i++)
{
    // multi-threaded read only accesses
    double seconds = json["S2_easy"]["seconds"];
    int count = json["S2_easy"].count("s2_easy");
}

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions