Discussion:
sleep, usleep and nanosleep (MySQL++ examples)
Rick Gutleber
2008-10-20 20:22:42 UTC
Permalink
Dear Plusplusers:

I have been recently discussing an idea with Warren concerning support
in the insert method for collections for creating the associated SQL
generated by the call according to a policy object passed in with the
call. This will allow MySQL++ calls to insert collections of object to
be mindful of MySQL's "maximum packet size" for queries transparently
such that the user does not need to worry about the size of the
collection to be inserted. The policy object could have other uses as
well, and will be open-ended in its design to allow to for new ideas.

Upon retrieving the code, and going through some iterations with the IT
guys to get our ancient OS up to date in order to support the MySQL++
build environment, I discovered that after running the "bootstrap"
script and doing a plain-vanilla build I was getting a compilation error
concerning usleep( ) in one of the example programs.

Similarly, in the past when building the multithread-aware version of
MySQL++, which is used in our project, I found that while the library
built just fine, one of the examples did not build because of the sleep(
) function. The multithread-aware version of MySQL++ can be built with
"./configure --enable-thread-check" which allows MySQL++ to run properly
in a multi-threaded application.

However, all these problems can be eliminated using the POSIX standard
nanosleep( ) function, which I'd never heard of until I did some Googlin'.

My question to my learned and esteemed listmates is: Are there any
reasons you know why this function would be unsuitable for use in the
MySQL++ example apps?

Rick
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-***@m.gmane.org
Warren Young
2008-10-20 21:22:39 UTC
Permalink
I was getting a compilation error concerning usleep( ) in one of the example programs.
That's probably examples/multiquery.cpp, which had debugging code
accidentally checked in. It's been removed from svn.
one of the examples did not build because of the sleep(
) function.
sleep() is POSIX. What platform are you on that doesn't have this,
which is also not Windows? (We use Sleep() there.)
nanosleep( ) function
Shouldn't be necessary now. We only use sleep() and Sleep(). If your
platform has neither, we can talk about making an ifdef case to
implement sleep() in terms of nanosleep(), but I think you'll find that
you really do have sleep(). Perhaps the examples just don't include a
necessary header for your platform.
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-***@m.gmane.org
Rick Gutleber
2008-10-21 13:31:14 UTC
Permalink
Post by Warren Young
That's probably examples/multiquery.cpp, which had debugging code
accidentally checked in. It's been removed from svn.
OK. I was wondering because I'd never seen that problem before.
Post by Warren Young
Shouldn't be necessary now. We only use sleep() and Sleep(). If your
platform has neither, we can talk about making an ifdef case to
implement sleep() in terms of nanosleep(), but I think you'll find
that you really do have sleep(). Perhaps the examples just don't
include a necessary header for your platform.
When you configure for multithread awareness the compiler can't find
sleep( ). It turns out that if you add "#include <unistd.h>" in
cpool.cpp it solves the problem.

Rick
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-***@m.gmane.org
Warren Young
2008-10-21 14:39:21 UTC
Permalink
Post by Rick Gutleber
It turns out that if you add "#include <unistd.h>" in
cpool.cpp it solves the problem.
Fixed in svn now.
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-***@m.gmane.org
Loading...