bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread termination & Mutex bug?


From: Jon Wilson
Subject: Re: Thread termination & Mutex bug?
Date: Tue, 01 Apr 2003 13:23:47 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130

I have a working build on win2000/XP without the use of LibXML. I removed(commented) the
#define HAVE_LIBXML
in win32/c++/config.h
And then simply compiled the source without the makefile. (excluding xml.cpp) and linked with
-lwsock32 -lws2_32.
I was using gcc3.2 under MingW and hence also had to remove HAVE_OLD_IOSTREAM
from the config as above.
You don't mention which compiler you are using?
Also there is a know issue with Thread::join() since it is in a #ifndef __WIN32__ and needs to be moved up the header outside of the block.
(That fix was sent to me by someone else on the group thanks again).
Hope this is of some help.
Jon Wilson

NTR wrote:

Hi,

I have been working with CommonC++ 1.9.1 on Win2000 using the Thread, Mutex,
Semaphore classes in a multi-threaded and I'm having problems with
terminating threads from "main(...)" as this cannot call "Terminate()" as it
is protected. What is the reason for this? Couldn't it be public instead?
Could I just derive my own thread class and make a public "MyTerminate"
method which calls "this->Terminate()"?

Anyway, I assume there is a good reason for this so ... how can I terminate
a thread from the main method? I have noticed the Thread(bool), which is
supposed to construct a context for the main thread. However, I have no idea
how to use this ... if anybody has an example it would be highly
appreciated.

In addition, I'm experiencing problems with Mutex and Semaphore not being
thread safe in a producer/consumer scenario. Is this a known bug in 1.9.1?

My scenario is something like:
main()
{
  ProducerConsumerBuffer buf;
  ProducerThread prod(buf);//Puts data in buf ... overwrites data in buf
  ConsumerThread cons(buf);//Waits on semaphore for data in buf
  prod.Start();
  cons.Start();

  ccxx_sleep(100000);//In my case I process user input until ESC has been
pressed

  //Due to various reasons I cannot simply let threads
  //delete themselves when the main thread stops but have
  //to stop the threads first
  prod.Terminate();//WRONG
  cons.Terminate();//WRONG
}

Regards,
Niels

PS: Is the new commoncpp2 1.0.x endiansafe for TCP transmission from a Win32
to an Irix 6.5 SGI computer? The reason I'm using 1.9.1 is that some other
people have modified this version to be endiansafe for TCP transmission. I
think they submitted a bug report...
PPS: I have previously downloaded commoncpp2 1.0.8, but haven't had any luck
compiling it (without XML) on Win2000 is this still a problem?


_______________________________________________
Bug-commoncpp mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/bug-commoncpp







reply via email to

[Prev in Thread] Current Thread [Next in Thread]