Boost logo

Boost Users :

From: Sliwa, Przemyslaw (London) (Przemyslaw_Sliwa_at_[hidden])
Date: 2005-04-19 03:27:58


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_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Ben Hutchings
Sent: 18 April 2005 19:37
To: boost-users_at_[hidden]
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_at_[hidden]
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/
--------------------------------------------------------


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net