mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-13 18:01:43 +01:00
works for get setttings and for loadsettingsfile
This commit is contained in:
@@ -94,7 +94,7 @@ int Multi::printNumber(int inum){
|
||||
iret[i]= new int(-1);
|
||||
//func_t <int,Single,int, int>* binder =
|
||||
// new func_t<int, Single,int, int>(&Single::printNumber,singles[i],inum,iret[i]);
|
||||
Task* task = new Task(new func_t<int, Single,int, int>(&Single::printNumber,singles[i],inum,iret[i]));
|
||||
Task* task = new Task(new func1_t<int, Single,int, int>(&Single::printNumber,singles[i],inum,iret[i]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
threadpool->wait_for_tasks_to_complete();
|
||||
@@ -125,8 +125,8 @@ string Multi::printString(string s){
|
||||
|
||||
for(int i=0;i<numSingles;i++){
|
||||
sret[i]= new string("sss");
|
||||
func_t <string,Single,string,string>* binder =
|
||||
new func_t<string,Single,string,string>(&Single::printString,singles[i],s,sret[i]);
|
||||
func1_t <string,Single,string,string>* binder =
|
||||
new func1_t<string,Single,string,string>(&Single::printString,singles[i],s,sret[i]);
|
||||
Task* task = new Task(binder);
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
@@ -164,8 +164,8 @@ char* Multi::printCharArray(char a[]){
|
||||
for(int i=0;i<numSingles;i++){
|
||||
sret[i]= new string("sss");
|
||||
//std::fill_n(cret[i],1000,0);
|
||||
func_t <char*,Single,char*,string>* binder =
|
||||
new func_t <char*,Single,char*,string>(&Single::printCharArray,singles[i],a,sret[i]);
|
||||
func1_t <char*,Single,char*,string>* binder =
|
||||
new func1_t <char*,Single,char*,string>(&Single::printCharArray,singles[i],a,sret[i]);
|
||||
Task* task = new Task(binder);
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
|
||||
@@ -18,13 +18,12 @@ class slsDetector;
|
||||
|
||||
|
||||
template<typename _Ret, typename _Class,typename _Arg1, typename _Store>
|
||||
class func_t{
|
||||
class func1_t{
|
||||
public:
|
||||
func_t(_Ret (_Class::*fn)(_Arg1),_Class* ptr,_Arg1 arg1, _Store* sto):m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_store(sto){}
|
||||
~func_t() {}
|
||||
|
||||
func1_t(_Ret (_Class::*fn)(_Arg1),_Class* ptr,_Arg1 arg1, _Store* sto):
|
||||
m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_store(sto){}
|
||||
~func1_t() {}
|
||||
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1));}
|
||||
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)(_Arg1);
|
||||
@@ -32,22 +31,53 @@ private:
|
||||
_Store* m_store;
|
||||
};
|
||||
|
||||
template<typename _Ret, typename _Class,typename _Arg1, typename _Arg2,typename _Store>
|
||||
class func2_t{
|
||||
public:
|
||||
func2_t(_Ret (_Class::*fn)(_Arg1,_Arg2),_Class* ptr,_Arg1 arg1,_Arg2 arg2,_Store* sto):
|
||||
m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_store(sto){}
|
||||
~func2_t() {}
|
||||
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2));}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)(_Arg1,_Arg2);
|
||||
_Arg1 m_arg1;
|
||||
_Arg2 m_arg2;
|
||||
_Store* m_store;
|
||||
};
|
||||
|
||||
template<typename _Ret, typename _Class,typename _Arg1, typename _Arg2, typename _Arg3, typename _Arg4,typename _Store>
|
||||
class func4_t{
|
||||
public:
|
||||
func4_t(_Ret (_Class::*fn)(_Arg1,_Arg2,_Arg3,_Arg4),_Class* ptr,_Arg1 arg1,_Arg2 arg2,_Arg3 arg3,_Arg4 arg4,_Store* sto):
|
||||
m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_arg3(arg3),m_arg4(arg4),m_store(sto){}
|
||||
~func4_t() {}
|
||||
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3,m_arg4));}
|
||||
private:
|
||||
_Class* m_ptr;
|
||||
_Ret (_Class::*m_fn)(_Arg1,_Arg2,_Arg3,_Arg4);
|
||||
_Arg1 m_arg1;
|
||||
_Arg2 m_arg2;
|
||||
_Arg3 m_arg3;
|
||||
_Arg4 m_arg4;
|
||||
_Store* m_store;
|
||||
};
|
||||
|
||||
class Task: public virtual slsDetectorDefs{
|
||||
public:
|
||||
Task(func_t <int,slsDetector,int,int>* t):m_int1(t),m_string1(0),m_chararr1(0),
|
||||
m_settings(0){};
|
||||
Task(func_t <string,slsDetector,string,string>* t): m_int1(0),m_string1(t),m_chararr1(0),
|
||||
m_settings(0){};
|
||||
Task(func_t <char*,slsDetector,char*,string>* t):m_int1(0),m_string1(0),m_chararr1(t),
|
||||
m_settings(0){};
|
||||
Task(func1_t <int,slsDetector,int,int>* t):
|
||||
m_int1(t),m_string1(0),m_chararr1(0),m_f2_1(0),m_settings(0){};
|
||||
Task(func1_t <string,slsDetector,string,string>* t):
|
||||
m_int1(0),m_string1(t),m_chararr1(0),m_f2_1(0),m_settings(0){};
|
||||
Task(func1_t <char*,slsDetector,char*,string>* t):
|
||||
m_int1(0),m_string1(0),m_chararr1(t),m_f2_1(0),m_settings(0){};
|
||||
|
||||
Task(func2_t <int,slsDetector,string,int,int>* t):
|
||||
m_int1(0),m_string1(0),m_chararr1(0),m_f2_1(t),m_settings(0){};
|
||||
|
||||
//settings
|
||||
Task(func_t <slsDetectorDefs::detectorSettings,slsDetector,int,int>* t):
|
||||
m_int1(0),m_string1(0),m_chararr1(0),
|
||||
m_settings(t)
|
||||
{};
|
||||
//specialized
|
||||
Task(func1_t <detectorSettings,slsDetector,int,int>* t):
|
||||
m_int1(0),m_string1(0),m_chararr1(0),m_f2_1(0),m_settings(t){};
|
||||
|
||||
~Task(){}
|
||||
|
||||
@@ -55,14 +85,22 @@ public:
|
||||
if(m_int1) (*m_int1)();
|
||||
else if(m_string1) (*m_string1)();
|
||||
else if(m_chararr1) (*m_chararr1)();
|
||||
|
||||
else if(m_f2_1) (*m_f2_1)();
|
||||
|
||||
//specialized
|
||||
else if(m_settings) (*m_settings)();
|
||||
}
|
||||
|
||||
private:
|
||||
func_t <int,slsDetector,int,int>* m_int1;
|
||||
func_t <string,slsDetector,string,string>* m_string1;
|
||||
func_t <char*,slsDetector,char*,string>* m_chararr1;
|
||||
func_t <slsDetectorDefs::detectorSettings,slsDetector,int,int>* m_settings;
|
||||
func1_t <int,slsDetector,int,int>* m_int1;
|
||||
func1_t <string,slsDetector,string,string>* m_string1;
|
||||
func1_t <char*,slsDetector,char*,string>* m_chararr1;
|
||||
func2_t <int,slsDetector,string,int,int>* m_f2_1;
|
||||
|
||||
//specialized
|
||||
func1_t <detectorSettings,slsDetector,int,int>* m_settings;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
ThreadPool::ThreadPool(int pool_size) : m_pool_size(pool_size)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
cout << "Constructed ThreadPool of size " << m_pool_size << endl;
|
||||
#endif
|
||||
m_tasks_loaded = false;
|
||||
thread_started = false;
|
||||
current_thread_number = -1;
|
||||
@@ -49,8 +51,9 @@ int ThreadPool::initialize_threadpool()
|
||||
m_threads.push_back(tid);
|
||||
while(!thread_started);
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
cout << m_pool_size << " threads created by the thread pool" << endl;
|
||||
|
||||
#endif
|
||||
return m_pool_size;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user