Is aerospike_query_foreach callback is thread safe or not

While implementing the callback of aerospike_query_foreach, is it required to make callback threadsafe, example: callback()

std::lock_guard < std::mutex > guard(campMutex);

vectorList.emplace_back(testValue);

Hi @vinay_negi

Yes, you need to make aerospike_query_foreach_callback thread safe, as multiple sub queries could be running and calling this callback function in parallel.

When you are using aerospike_query_foreach, query commands to each node in the cluster is run in parallel threads.

aerospike_query_foreach_callback

Multiple threads will likely be calling the callback in parallel. Therefore, your callback implementation should be thread safe.

© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.