|
-
May 19th, 2009, 11:58 PM
#1
C++ - Using STL queue dumps core
Hi All,
I am having a C++ application which loads a dynamic library (.so on UNIX and .dll on Windows). In the dynamic library, I have two threads. One is the reader and the other is the writer.
The writer accepts data from the C++ application and puts it onto a STL queue using push. The reader thread reads data from the queue using front and pop. However, the C++ application dumps a core after running for around one day.
The data thats written onto the queue is a class object. The class is
class OBJ
{
public:
OBJ() {};
~OBJ() {};
OBJ( char * name, int type, char * value) {
this->countername = name;
this->countertype = type;
this->countervalue = value;
}
const char * getCounterName() {
return A.c_str();
}
int getCounterType() {
return B;
}
const char * getCounterValue() {
return C.c_str();
}
protected:
string A;
int B;
string C;
};
The writer thread calls the following to push data:
push( OBJ(szXYZ, idata, szMNO ));
The reader thread calls the following to read and pop data:
OBJ obj;
if ( (size = QUEUE.size()) > 0 ) {
obj = QUEUE.front();
QUEUE.pop();
}
Is anything wrong with this? I see the core dump after about a day on Solaris 8 SPARC.
Thanks
Pankaj
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|