Hello everyone,
I'm currently attempting to create a thread within a thread, and for some reason, the constructor seems to block and things just don't work very well.
Consider a class ``BackupHandler'' and a class ``BackupHandlerThread'' - the thread is created for once in the 50ms polling to an output file which
might be used by other processes. Now, in BackupHandler, I do this:
---
boost::thread thread ( BackupHandlerThread (this->backupFile, this->data) );
---
Which, as far as I am aware of, should first create a BackupHandlerThread object, and then "launch" the thread with this object. Now, since I print out
some debug info, it seems like it reaches the BackupHandlerThread constructor once, and the destructor twice. The function
BackupHandlerThread::operator() () never is reached even once, and the execution of the initial thread blocks at the creation.
Also, according to gdb there is no new thread being created, and it adds any use, this is the stacktrace of the thread that should create the new
thread:
---
[Switching to thread 3 (Thread 16386 (LWP 24085))]#0 0x401d2b94 in __pthread_sigsuspend () from /lib/i686/libpthread.so.0
(gdb) bt
#0 0x401d2b94 in __pthread_sigsuspend () from /lib/i686/libpthread.so.0
#1 0x401d29d8 in __pthread_wait_for_restart_signal () from /lib/i686/libpthread.so.0
#2 0x401d2151 in pthread_create@@GLIBC_2.1 () from /lib/i686/libpthread.so.0
#3 0x400a5fc6 in boost::thread::thread(boost::function0