RE: [Boost-users] RE: Boost thread problem
Ben, Thank you for this. Your reply was very useful, I will have a look at it. Thanks again, Pshemek -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Ben Hutchings Sent: 18 April 2005 19:37 To: boost-users@lists.boost.org Subject: Re: [Boost-users] RE: Boost thread problem Sliwa, Przemyslaw (London) wrote:
The CFXTrade is a dummy class. Here is the simple code,
Pshemek
Well, there's nothing wrong with CFXTrade, but at least I know I have a complete program to look at now. read_trades() copies TradeVector without locking the mutex that should protect it. It should be passing boost::ref(TradeVector) to boost::bind instead of TradeVector, or maybe not passing an argument at all. This is probably what's responsible for the crash. Other problems I spotted: - read_from_disk doesn't use its argument; it uses TradeVector directly - generate_file is not exception-safe - if thread creation fails, out will not be closed and other child threads will not be joined - generate_file also copies the vector it passes to threads (but this does not affect correctness and so long as generate_file may exit without joining the child thread it is unsafe to pass a reference) - getTradeFromString has no error-handling Ben. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users -------------------------------------------------------- If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail. http://www.ml.com/email_terms/ --------------------------------------------------------
participants (1)
-
Sliwa, Przemyslaw (London)