17#ifdef USE_BOOST_MULTITHREADING
18NameStack& NameStack::operator=(
const NameStack& f) {
19#ifdef USE_TOGETHER_WITH_CLEAN_NEW
20#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
21 MemoriseIgnore::instance().ignore();
23 s_ignore_keynumberlist = 1;
29 for (n = 0; n < qname; n++)
delete name[n];
33 for (n = 0; n < f.qname; n++) {
37 int l = strlen(f.name[n]) + 1;
38 name[n] =
new char[l];
39 strcpy(name[n], f.name[n]);
43#ifdef USE_TOGETHER_WITH_CLEAN_NEW
44#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
45 MemoriseIgnore::instance().not_ignore();
47 s_ignore_keynumberlist = 0;
65#ifdef USE_BOOST_MULTITHREADING
66#ifdef PRINT_BEFORE_LOCK
67 fprintf(stderr,
"FunNameStack& FunNameStack::instance()\n");
69 boost::mutex locked_object;
70 boost::mutex::scoped_lock scopedLock_object(locked_object);
76#ifdef USE_TOGETHER_WITH_CLEAN_NEW
77#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
78 MemoriseIgnore::instance().ignore();
80 s_ignore_keynumberlist = 1;
84#ifdef USE_TOGETHER_WITH_CLEAN_NEW
85#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
86 MemoriseIgnore::instance().not_ignore();
88 s_ignore_keynumberlist = 0;
100#ifdef USE_BOOST_MULTITHREADING
102#ifdef USE_TOGETHER_WITH_CLEAN_NEW
103#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
104 MemoriseIgnore::instance().ignore();
106 s_ignore_keynumberlist = 1;
109 namestack =
new std::list<NameStack>;
110 namestack->push_back(NameStack());
111#ifdef USE_TOGETHER_WITH_CLEAN_NEW
112#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
113 MemoriseIgnore::instance().not_ignore();
115 s_ignore_keynumberlist = 0;
119 pthread_t
id = pthread_self();
120 namestack->back().id = id;
121#ifdef PRINT_MESSAGE_ABOUT_THREAD_INITIALIZATION
123 <<
"-----------------------------------------------------------------\n";
125 <<
"-----------------------------------------------------------------\n";
127 <<
"-----------------------------------------------------------------\n";
129 <<
"-----------------------------------------------------------------\n";
131 <<
"-----------------------------------------------------------------\n";
132 mcerr <<
"FunNameStack::FunNameStack(void) const:\n";
133 mcerr <<
"thread is initialized:\n";
136 <<
"-----------------------------------------------------------------\n";
138 <<
"-----------------------------------------------------------------\n";
140 <<
"-----------------------------------------------------------------\n";
142 <<
"-----------------------------------------------------------------\n";
144 <<
"-----------------------------------------------------------------\n";
148 for (
int n = 0; n < pqname; n++) name[n] = NULL;
152#ifdef USE_BOOST_MULTITHREADING
153NameStack* FunNameStack::get_thread_stack(
void)
const {
155 pthread_t
id = pthread_self();
157 std::list<NameStack>::const_iterator it;
158 std::list<NameStack>::const_iterator end = namestack->end();
159 for (it = namestack->begin(); it != end; ++it) {
160 if (pthread_equal((*it).id,
id)) {
178#ifdef USE_TOGETHER_WITH_CLEAN_NEW
179#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
180 MemoriseIgnore::instance().ignore();
182 s_ignore_keynumberlist = 1;
185 namestack->push_back(NameStack());
186#ifdef USE_TOGETHER_WITH_CLEAN_NEW
187#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
188 MemoriseIgnore::instance().not_ignore();
190 s_ignore_keynumberlist = 0;
194 namestack->back().id = id;
196 return &(namestack - back());
198NameStack* FunNameStack::get_thread_stack_q(
long& nthread,
199 long& qthread)
const {
202 pthread_t
id = pthread_self();
204 std::list<NameStack>::const_iterator it;
205 std::list<NameStack>::const_iterator end = namestack->end();
206 for (it = namestack->begin(); it != end; ++it) {
207 if (s_found == 0 && pthread_equal((*it).id,
id)) {
226#ifdef USE_TOGETHER_WITH_CLEAN_NEW
227#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
228 MemoriseIgnore::instance().ignore();
230 s_ignore_keynumberlist = 1;
233 namestack->push_back(NameStack());
234#ifdef USE_TOGETHER_WITH_CLEAN_NEW
235#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
236 MemoriseIgnore::instance().not_ignore();
238 s_ignore_keynumberlist = 0;
241 namestack->back().id = id;
245 return &(namestack->back());
247void FunNameStack::remove_thread_stack(
void) {
248 pthread_t
id = pthread_self();
250 std::list<NameStack>::const_iterator it;
251 std::list<NameStack>::const_iterator end = namestack->end();
252 for (it = namestack->begin(); it != end; ++it) {
253 if (pthread_equal((*it).id,
id)) {
260 mcerr <<
"ERROR in void FunNameStack::remove_thread_stack(void) const:\n";
261 mcerr <<
"new thread is detected\n";
265#ifdef USE_TOGETHER_WITH_CLEAN_NEW
266#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
267 MemoriseIgnore::instance().ignore();
269 s_ignore_keynumberlist = 1;
272 namestack->remove(an);
273#ifdef USE_TOGETHER_WITH_CLEAN_NEW
274#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
275 MemoriseIgnore::instance().not_ignore();
277 s_ignore_keynumberlist = 0;
283#ifdef USE_BOOST_MULTITHREADING
284std::ostream& FunNameStack::printname(std::ostream& file, NameStack* ns,
287std::ostream& FunNameStack::printname(std::ostream& file,
int n)
290#ifdef USE_BOOST_MULTITHREADING
300 file <<
"spexit_action: the streams will be now flushed\n";
306 file <<
"spexit_action: the exit(1) function is called\n";
309 file <<
"spexit_action: the abort function is called\n";
313 file <<
"spexit_action: an exception is now called\n";
322 mcerr <<
"ERROR in FunNameStack& FunNameStack::operator=(const "
323 "FunNameStack& f)\n";
324 mcerr <<
"Attempt to copy to operative FunNameStack\n";
325 mcerr <<
"You don't need and should not initialize main FunNameStack "
327 mcerr <<
"If you want to change its parameters, use "
328 "FunNameStack::instance()\n";
336#ifdef USE_BOOST_MULTITHREADING
338#ifdef USE_TOGETHER_WITH_CLEAN_NEW
339#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
340 MemoriseIgnore::instance().ignore();
342 s_ignore_keynumberlist = 1;
345 if (namestack)
delete namestack;
346 namestack =
new std::list<NameStack>(*(f.namestack));
347#ifdef USE_TOGETHER_WITH_CLEAN_NEW
348#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
349 MemoriseIgnore::instance().not_ignore();
351 s_ignore_keynumberlist = 0;
362#ifdef USE_BOOST_MULTITHREADING
364 for (
int n = 0; n < f.qname; n++) {
368 int l = strlen(f.name[n]) + 1;
369#ifdef USE_TOGETHER_WITH_CLEAN_NEW
370 s_ignore_keynumberlist = 1;
372 name[n] =
new char[l];
373 strcpy(name[n], f.name[n]);
374#ifdef USE_TOGETHER_WITH_CLEAN_NEW
375 s_ignore_keynumberlist = 0;
389#ifdef USE_BOOST_MULTITHREADING
390#ifdef USE_TOGETHER_WITH_CLEAN_NEW
391#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
392 MemoriseIgnore::instance().ignore();
394 s_ignore_keynumberlist = 1;
397 if (namestack)
delete namestack;
398#ifdef USE_TOGETHER_WITH_CLEAN_NEW
399#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
400 MemoriseIgnore::instance().not_ignore();
402 s_ignore_keynumberlist = 0;
406#ifdef USE_TOGETHER_WITH_CLEAN_NEW
407 s_ignore_keynumberlist = 1;
410 for (
int n = 0; n < qname; n++)
delete name[n];
411#ifdef USE_TOGETHER_WITH_CLEAN_NEW
412 s_ignore_keynumberlist = 0;
417void FunNameStack::printput(std::ostream& file) {
419#ifdef USE_BOOST_MULTITHREADING
420 NameStack* ns = get_thread_stack();
421 file <<
"FunNameStack::put: id=" << ns->id <<
" qname=" << ns->qname
423 printname(file, ns, ns->qname - 1);
426 file <<
"FunNameStack::put: qname =" << qname <<
" last name=";
427 printname(file, qname - 1) <<
'\n';
430#ifdef USE_BOOST_MULTITHREADING
431 NameStack* ns = get_thread_stack();
432 file <<
"FunNameStack::put: id=" << ns->id <<
"\n" << (*this);
434 file <<
"FunNameStack::put:\n" << (*this);
438void FunNameStack::printdel(std::ostream& file) {
440#ifdef USE_BOOST_MULTITHREADING
441 NameStack* ns = get_thread_stack();
442 file <<
"FunNameStack::del: id=" << ns->id <<
" qname =" << ns->qname
444 printname(file, ns, ns->qname - 1);
447 file <<
"FunNameStack::del: qname =" << qname <<
" last name=";
448 printname(file, qname - 1) <<
'\n';
451 file <<
"FunNameStack::del:\n" << (*this);
457#ifdef USE_BOOST_MULTITHREADING
458 file <<
"FunNameStack: s_init=" << f.s_init <<
'\n';
460 NameStack* ns = f.get_thread_stack_q(nret, qret);
461 file <<
" id=" << ns->id <<
" qname=" << ns->qname <<
'\n';
462 file <<
"At the time of scanning there were " << qret <<
" threads \n"
463 <<
"registered in FunNameStack system.\n";
464 file <<
"The current one appeared nth: " << nret <<
'\n';
465 for (
int n = 0; n < ns->qname; n++) {
466 file << std::setw(3) << n <<
" " << ns->name[n] <<
" \n";
469 file <<
"FunNameStack: s_init=" << f.s_init <<
" qname=" << f.qname <<
'\n';
470 for (
int n = 0; n < f.qname; n++) {
471 file << std::setw(3) << n <<
" " << f.name[n] <<
" \n";
static FunNameStack & instance()
FunNameStack & operator=(const FunNameStack &f)
void set_parameters(int fs_act=1, int fs_print=0)
std::ostream & hdr(std::ostream &file) const
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
void spexit_action(std::ostream &file)
int s_throw_exception_in_spexit
#define Iprintn(file, name)