Commit 1af4ffbc authored by Matthieu Dorier's avatar Matthieu Dorier

added possibility to use a progres thread on clients

parent 663cc522
......@@ -18,6 +18,7 @@ class RunSet;
class Run;
class SubRun;
class Event;
class EventSet;
class DataStoreImpl;
class DataSetImpl;
class RunSetImpl;
......@@ -41,6 +42,7 @@ class DataStore {
friend class WriteBatch;
friend class DataStoreImpl;
friend class AsyncEngine;
friend class EventSet;
public:
......@@ -48,8 +50,10 @@ class DataStore {
* @brief Constructor. Initializes the DataStore by taking
* the name of the configuration file from the environment
* variable HEPNOS_CONFIG_FILE.
*
* @param use_progress_thread whether to use a background thread for networking.
*/
static DataStore connect();
static DataStore connect(bool use_progress_thread=false);
/**
* @brief Constructor. Initializes the DataStore using a YAML
......@@ -57,8 +61,9 @@ class DataStore {
* service when started.
*
* @param configFile Path to a YAML configuration file.
* @param use_progress_thread whether to use a background thread for networking.
*/
static DataStore connect(const std::string& configFile);
static DataStore connect(const std::string& configFile, bool use_progress_thread=false);
/**
* @brief Default constructor (for an invalid DataStore not yet initialized).
......
......@@ -34,19 +34,19 @@ DataSet DataStore::root() const {
return DataSet(std::make_shared<DataSetImpl>(m_impl, 0, std::make_shared<std::string>(""), ""));
}
DataStore DataStore::connect() {
DataStore DataStore::connect(bool use_progress_thread) {
char* file = getenv("HEPNOS_CONFIG_FILE");
if(file == nullptr)
throw Exception("HEPNOS_CONFIG_FILE environment variable not set");
std::string configFile(file);
auto impl = std::make_shared<DataStoreImpl>();
impl->init(configFile);
impl->init(configFile, use_progress_thread);
return DataStore(std::move(impl));
}
DataStore DataStore::connect(const std::string& configFile) {
DataStore DataStore::connect(const std::string& configFile, bool use_progress_thread) {
auto impl = std::make_shared<DataStoreImpl>();
impl->init(configFile);
impl->init(configFile, use_progress_thread);
return DataStore(std::move(impl));
}
......
......@@ -102,7 +102,7 @@ class DataStoreImpl {
db_info.chi = ch_placement_initialize("hash_lookup3", db_info.dbs.size(), 4, 0);
}
void init(const std::string& configFile) {
void init(const std::string& configFile, bool use_progress_thread) {
int ret;
hg_return_t hret;
YAML::Node config = YAML::LoadFile(configFile);
......@@ -110,7 +110,7 @@ class DataStoreImpl {
// get protocol
std::string proto = config["hepnos"]["client"]["protocol"].as<std::string>();
// initialize Margo
m_mid = margo_init(proto.c_str(), MARGO_CLIENT_MODE, 0, 0);
m_mid = margo_init(proto.c_str(), MARGO_CLIENT_MODE, use_progress_thread, 0);
if(!m_mid) {
cleanup();
throw Exception("Could not initialized Margo");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment