implemented configuration for thread structure. Still crashes, but not often...

This commit is contained in:
Jean-Francois Dockes
2012-11-29 17:26:48 +01:00
parent 5c6db5331c
commit 9146929f5e
10 changed files with 368 additions and 177 deletions
+32 -10
View File
@@ -343,26 +343,48 @@ bool RclConfig::getConfParam(const string &name, vector<string> *svvp) const
return false;
return stringToStrings(s, *svvp);
}
bool RclConfig::getConfParam(const string &name, list<string> *svvp) const
bool RclConfig::getConfParam(const string &name, vector<int> *vip) const
{
if (!svvp)
if (!vip)
return false;
svvp->clear();
string s;
if (!getConfParam(name, s))
vip->clear();
vector<string> vs;
if (!getConfParam(name, &vs))
return false;
return stringToStrings(s, *svvp);
vip->reserve(vs.size());
for (unsigned int i = 0; i < vs.size(); i++) {
char *ep;
vip->push_back(strtol(vs[i].c_str(), &ep, 0));
if (ep == vs[i].c_str()) {
LOGDEB(("RclConfig::getConfParam: bad int value in [%s]\n",
name.c_str()));
return false;
}
}
return true;
}
list<string> RclConfig::getTopdirs() const
pair<int,int> RclConfig::getThrConf(ThrStage who) const
{
list<string> tdl;
vector<int> vq;
vector<int> vt;
if (!getConfParam("thrQSizes", &vq) || !getConfParam("thrTCounts", &vt)) {
return pair<int,int>(-1,-1);
}
return pair<int,int>(vq[who], vt[who]);
}
vector<string> RclConfig::getTopdirs() const
{
vector<string> tdl;
if (!getConfParam("topdirs", &tdl)) {
LOGERR(("RclConfig::getTopdirs: no top directories in config or bad list format\n"));
LOGERR(("RclConfig::getTopdirs: no top directories in config or "
"bad list format\n"));
return tdl;
}
for (list<string>::iterator it = tdl.begin(); it != tdl.end(); it++) {
for (vector<string>::iterator it = tdl.begin(); it != tdl.end(); it++) {
*it = path_tildexpand(*it);
*it = path_canon(*it);
}
+7 -3
View File
@@ -112,10 +112,14 @@ class RclConfig {
bool getConfParam(const string &name, int *value) const;
/** Variant with autoconversion to bool */
bool getConfParam(const string &name, bool *value) const;
/** Variant with conversion to string list/vector
/** Variant with conversion to vector<string>
* (stringToStrings). Can fail if the string is malformed. */
bool getConfParam(const string &name, vector<string> *value) const;
bool getConfParam(const string &name, list<string> *value) const;
/** Variant with conversion to vector<int> */
bool getConfParam(const string &name, vector<int> *value) const;
enum ThrStage {ThrIntern=0, ThrSplit=1, ThrDbWrite=2};
pair<int, int> getThrConf(ThrStage who) const;
/**
* Get list of config names under current sk, with possible
@@ -140,7 +144,7 @@ class RclConfig {
/** Get list of top directories. This is needed from a number of places
* and needs some cleaning-up code. An empty list is always an error, no
* need for other status */
list<string> getTopdirs() const;
vector<string> getTopdirs() const;
/** Get database directory */
string getDbDir() const;