16#ifdef USE_BOOST_MULTITHREADING
22#ifdef USE_TOGETHER_WITH_CLEAN_NEW
23#include "wcpplib/util/clean_new.h"
26#ifdef USE_BOOST_MULTITHREADING
27NameStack& NameStack::operator=(
const NameStack& f) {
28#ifdef USE_TOGETHER_WITH_CLEAN_NEW
29#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
30 MemoriseIgnore::instance().ignore();
32 s_ignore_keynumberlist = 1;
37 if (nmode == 1)
for (n = 0; n < qname; n++)
42 for (n = 0; n < f.qname; n++) {
46 int l = strlen(f.name[n]) + 1;
47 name[n] =
new char[l];
48 strcpy(name[n], f.name[n]);
52#ifdef USE_TOGETHER_WITH_CLEAN_NEW
53#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
54 MemoriseIgnore::instance().not_ignore();
56 s_ignore_keynumberlist = 0;
72#ifdef USE_BOOST_MULTITHREADING
73#ifdef PRINT_BEFORE_LOCK
74 fprintf(stderr,
"FunNameStack& FunNameStack::instance()\n");
76 boost::mutex locked_object;
77 boost::mutex::scoped_lock scopedLock_object(locked_object);
83#ifdef USE_TOGETHER_WITH_CLEAN_NEW
84#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
85 MemoriseIgnore::instance().ignore();
87 s_ignore_keynumberlist = 1;
91#ifdef USE_TOGETHER_WITH_CLEAN_NEW
92#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
93 MemoriseIgnore::instance().not_ignore();
95 s_ignore_keynumberlist = 0;
107#ifdef USE_BOOST_MULTITHREADING
109#ifdef USE_TOGETHER_WITH_CLEAN_NEW
110#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
111 MemoriseIgnore::instance().ignore();
113 s_ignore_keynumberlist = 1;
117 namestack->
append(NameStack());
118#ifdef USE_TOGETHER_WITH_CLEAN_NEW
119#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
120 MemoriseIgnore::instance().not_ignore();
122 s_ignore_keynumberlist = 0;
126 pthread_t
id = pthread_self();
127 namestack->get_last_node()->el.id = id;
128#ifdef PRINT_MESSAGE_ABOUT_THREAD_INITIALIZATION
130 <<
"-----------------------------------------------------------------\n";
132 <<
"-----------------------------------------------------------------\n";
134 <<
"-----------------------------------------------------------------\n";
136 <<
"-----------------------------------------------------------------\n";
138 <<
"-----------------------------------------------------------------\n";
139 mcerr <<
"FunNameStack::FunNameStack(void) const:\n";
140 mcerr <<
"thread is initialized:\n";
143 <<
"-----------------------------------------------------------------\n";
145 <<
"-----------------------------------------------------------------\n";
147 <<
"-----------------------------------------------------------------\n";
149 <<
"-----------------------------------------------------------------\n";
151 <<
"-----------------------------------------------------------------\n";
155 for (
int n = 0; n <
pqname; n++)
160#ifdef USE_BOOST_MULTITHREADING
161NameStack* FunNameStack::get_thread_stack(
void)
const {
163 pthread_t
id = pthread_self();
166 an = namestack->get_first_node();
168 if (pthread_equal(an->el.id,
id)) {
172 an =
an->get_next_node();
188#ifdef USE_TOGETHER_WITH_CLEAN_NEW
189#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
190 MemoriseIgnore::instance().ignore();
192 s_ignore_keynumberlist = 1;
195 namestack->append(NameStack());
196#ifdef USE_TOGETHER_WITH_CLEAN_NEW
197#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
198 MemoriseIgnore::instance().not_ignore();
200 s_ignore_keynumberlist = 0;
204 namestack->get_last_node()->el.id = id;
206 return &(namestack->get_last_node()->el);
208NameStack* FunNameStack::get_thread_stack_q(
long& nthread,
209 long& qthread)
const {
212 pthread_t
id = pthread_self();
215 an = namestack->get_first_node();
217 if (s_found == 0 && pthread_equal(
an->el.id,
id)) {
221 an =
an->get_next_node();
237#ifdef USE_TOGETHER_WITH_CLEAN_NEW
238#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
239 MemoriseIgnore::instance().ignore();
241 s_ignore_keynumberlist = 1;
244 namestack->append(NameStack());
245#ifdef USE_TOGETHER_WITH_CLEAN_NEW
246#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
247 MemoriseIgnore::instance().not_ignore();
249 s_ignore_keynumberlist = 0;
252 namestack->get_last_node()->el.id = id;
257 return &(namestack->get_last_node()->el);
259void FunNameStack::remove_thread_stack(
void) {
261 pthread_t
id = pthread_self();
264 an = namestack->get_first_node();
266 if (pthread_equal(
an->el.id,
id)) {
270 an =
an->get_next_node();
275 mcerr <<
"ERROR in void FunNameStack::remove_thread_stack(void) const:\n";
276 mcerr <<
"new thread is detected\n";
280#ifdef USE_TOGETHER_WITH_CLEAN_NEW
281#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
282 MemoriseIgnore::instance().ignore();
284 s_ignore_keynumberlist = 1;
287 namestack->remove(an);
288#ifdef USE_TOGETHER_WITH_CLEAN_NEW
289#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
290 MemoriseIgnore::instance().not_ignore();
292 s_ignore_keynumberlist = 0;
298#ifdef USE_BOOST_MULTITHREADING
299std::ostream& FunNameStack::printname(std::ostream& file, NameStack* ns,
302 std::ostream& FunNameStack::printname(std::ostream& file,
int n)
305#ifdef USE_BOOST_MULTITHREADING
315 file <<
"spexit_action: the streams will be now flushed\n";
321 file <<
"spexit_action: the exit(1) function is called\n";
324 file <<
"spexit_action: the abort function is called\n";
328 file <<
"spexit_action: an exception is now called\n";
337 mcerr <<
"ERROR in FunNameStack& FunNameStack::operator=(const "
338 "FunNameStack& f)\n";
339 mcerr <<
"Attempt to copy to operative FunNameStack\n";
340 mcerr <<
"You don't need and should not initialize main FunNameStack "
342 mcerr <<
"If you want to change its parameters, use "
343 "FunNameStack::instance()\n";
351#ifdef USE_BOOST_MULTITHREADING
353#ifdef USE_TOGETHER_WITH_CLEAN_NEW
354#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
355 MemoriseIgnore::instance().ignore();
357 s_ignore_keynumberlist = 1;
360 if (namestack != NULL)
delete namestack;
362#ifdef USE_TOGETHER_WITH_CLEAN_NEW
363#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
364 MemoriseIgnore::instance().not_ignore();
366 s_ignore_keynumberlist = 0;
377#ifdef USE_BOOST_MULTITHREADING
380 for (n = 0; n < f.qname; n++) {
384 int l = strlen(f.name[n]) + 1;
385#ifdef USE_TOGETHER_WITH_CLEAN_NEW
386 s_ignore_keynumberlist = 1;
388 name[n] =
new char[l];
389 strcpy(name[n], f.name[n]);
390#ifdef USE_TOGETHER_WITH_CLEAN_NEW
391 s_ignore_keynumberlist = 0;
405#ifdef USE_BOOST_MULTITHREADING
406#ifdef USE_TOGETHER_WITH_CLEAN_NEW
407#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
408 MemoriseIgnore::instance().ignore();
410 s_ignore_keynumberlist = 1;
413 if (namestack != NULL)
delete namestack;
414#ifdef USE_TOGETHER_WITH_CLEAN_NEW
415#if defined(MAINTAIN_KEYNUMBER_LIST) && defined(USE_BOOST_MULTITHREADING)
416 MemoriseIgnore::instance().not_ignore();
418 s_ignore_keynumberlist = 0;
423#ifdef USE_TOGETHER_WITH_CLEAN_NEW
424 s_ignore_keynumberlist = 1;
426 if (nmode == 1)
for (n = 0; n < qname; n++)
428#ifdef USE_TOGETHER_WITH_CLEAN_NEW
429 s_ignore_keynumberlist = 0;
434#ifndef WCPPLIB_INLINE
435#include "util/FunNameStack.ic"
438void FunNameStack::printput(std::ostream& file) {
440#ifdef USE_BOOST_MULTITHREADING
441 NameStack* ns = get_thread_stack();
442 file <<
"FunNameStack::put: id=" << ns->id <<
" qname=" << ns->qname
444 printname(file, ns, ns->qname - 1);
447 file <<
"FunNameStack::put: qname =" << qname <<
" last name=";
448 printname(file, qname - 1) <<
'\n';
451#ifdef USE_BOOST_MULTITHREADING
452 NameStack* ns = get_thread_stack();
453 file <<
"FunNameStack::put: id=" << ns->id <<
"\n" << (*this);
455 file <<
"FunNameStack::put:\n" << (*this);
459void FunNameStack::printdel(std::ostream& file) {
461#ifdef USE_BOOST_MULTITHREADING
462 NameStack* ns = get_thread_stack();
463 file <<
"FunNameStack::del: id=" << ns->id <<
" qname =" << ns->qname
465 printname(file, ns, ns->qname - 1);
468 file <<
"FunNameStack::del: qname =" << qname <<
" last name=";
469 printname(file, qname - 1) <<
'\n';
472 file <<
"FunNameStack::del:\n" << (*this);
478#ifdef USE_BOOST_MULTITHREADING
479 file <<
"FunNameStack: s_init=" << f.s_init <<
'\n';
481 NameStack* ns = f.get_thread_stack_q(nret, qret);
482 file <<
" id=" << ns->id <<
" qname=" << ns->qname <<
'\n';
483 file <<
"At the time of scanning there were " << qret <<
" threads \n"
484 <<
"registered in FunNameStack system.\n";
485 file <<
"The current one appeared nth: " << nret <<
'\n';
487 for (n = 0; n < ns->qname; n++) {
489 file << std::setw(3) << n <<
" " << ns->name[n] <<
" \n";
492 file <<
"FunNameStack: s_init=" << f.s_init <<
" qname=" << f.qname <<
'\n';
494 for (n = 0; n < f.qname; n++) {
496 file << std::setw(3) << n <<
" " << f.name[n] <<
" \n";
510 file <<
"GenError::print: ERROR detected in:\n"
std::ostream & operator<<(std::ostream &file, const FunNameStack &f)
void spexit_action(std::ostream &file)
int s_throw_exception_in_spexit
AbsListNode< T > * append(const T &fel)
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
virtual void print(std::ostream &file)
virtual void finish(std::ostream &file)
#define statcast(type, name)
#define Iprintn(file, name)