The following code demonstrate that the ObjectData function is not thread safe and throws std::runtime_error exception.
#include <thread>
#include <ipfs/client.h>
int main()
{
auto hash = "QmcXneAawME7d3vmV3x95p3WVxczeTid7LpJW8DcH4sA5c";
ipfs::Client ipfs("localhost", 5001);
std::thread t1([&hash, &ipfs]() { std::string data; ipfs.ObjectData(hash, &data); });
std::thread t2([&hash, &ipfs]() { std::string data; ipfs.ObjectData(hash, &data); });
t1.join();
t2.join();
return (0);
}
On MacOS:
libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Failed initialization
The following code demonstrate that the ObjectData function is not thread safe and throws std::runtime_error exception.
On MacOS:
libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Failed initialization