The title pretty much conveys all the relevant information, but here's the minimal reproduction:
#include <atomic>
#include <cstdio>
#include <memory>
int main() {
auto ptr = std::make_shared<int>(0);
bool is_lockless = std::atomic_is_lock_free(&ptr);
printf("shared_ptr is lockless: %d\n", is_lockless);
}
Compilation using the following compiler options creates an implementation without blocking shared_ptr:
g++ -std=c++11 -march=native main.cpp
So far this is not the case:
g++ -std=c++11 -march=native -pthread main.cpp
GCCversion: 5.3.0(on Linux, using libstdc++), tested on several machines, which must have the necessary atomic instructions to make this work.
Is there a way to force the implementation to be blocked (I need a free version, regardless of performance)?
source
share