List:MySQL++« Previous MessageNext Message »
From:Damien Kick Date:July 11 2014 8:46pm
Subject:Re: Problem with attempt to share a Connection between threads
View as plain text  
On Jul 11, 2014, at 3:15 PM, <willem.meert@stripped<mailto:willem.meert@stripped>>
 wrote:

So basically, your example consists of making 8 threads, each of which do the following work: open a connection, fire off 100 queries, done.
It should work, but in case of problems (database hits connection limit, …), you are not checking anything and you’ll be using a NULL address: if the connection setup fails → cxn will be null → cxn.query will segfault in your for loop;

Actually, I was expecting that any error case would throw an exception with the code as I've written it; i.e. we would crash in a call to std::terminate but not a segfault.  I may be mistaken in that regard, too, though.  Am I?  But please note that these are just silly exercises; i.e., I would most certainly want to add error handling for cases like you mention, Willem, in any kind of "real world" code.

________________________________

This e-mail and any attachments are confidential. If it is not intended for you, please notify the sender, and please erase and ignore the contents.
Thread
Problem with attempt to share a Connection between threadsDamien Kick10 Jul 2014
  • Re: Problem with attempt to share a Connection between threadsWarren Young11 Jul 2014
    • Re: Problem with attempt to share a Connection between threadsDamien Kick11 Jul 2014
      • Re: Problem with attempt to share a Connection between threadsWarren Young11 Jul 2014
        • Re: Problem with attempt to share a Connection between threadsDamien Kick11 Jul 2014
          • Re: Problem with attempt to share a Connection between threadsWarren Young11 Jul 2014
            • Re: Problem with attempt to share a Connection between threadsDamien Kick11 Jul 2014
              • Re: Problem with attempt to share a Connection between threadsDamien Kick11 Jul 2014
                • Re: Problem with attempt to share a Connection between threadsWarren Young11 Jul 2014
              • Re: Problem with attempt to share a Connection between threadsWarren Young11 Jul 2014
                • Re: Problem with attempt to share a Connection between threadsDamien Kick11 Jul 2014
                  • Re: Problem with attempt to share a Connection between threadsWarren Young11 Jul 2014
                    • Re: Problem with attempt to share a Connection between threadsDamien Kick11 Jul 2014
                      • Re: Problem with attempt to share a Connection between threadsAdrian Cornish11 Jul 2014
  • Re: Problem with attempt to share a Connection between threadsChris Frey13 Jul 2014
Re: Problem with attempt to share a Connection between threadsDamien Kick11 Jul 2014
  • Re: Problem with attempt to share a Connection between threadsWarren Young11 Jul 2014