Hi,
I tried to review some code inside mysqlpp and possibly modify it for me
(I want to replace some parts with code from other libraries, eg
boost.date_time etc, since I use date_time in my app) and I found some
strange code
class Lock, BasicLock, and Locable are strange pieces of code in my
point of view. First of all, there's no need to have virtual methods for
such simple class. Locable has a really doubtful piece of code - it
creates BasicLock using new! I find it to be really strange, as I don't
see any need to have pointer to an object that's one byte in size.
Perhaps, the intention was to have possibility replace underlying Lock
with some other Lock object, but isn't it's strange to change threading
models at runtime? As with my first mail I may be wrong without knowing
the underlying code, but why it was designed this way? I think I never
saw anything like this.
This issue is well discussed in "Modern C++ Design" and loki-lib has
some good code for implementing it.
basically, from this book it seem that a better decision is:
template<template <class> ThreadingModel>
class connection : ThreadingModel<connection> {}
and inside connection::method(){
lock(*this);
//do something...
}
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe:
http://lists.mysql.com/plusplus?unsub=gcdmc-plusplus@xxxxxxxxxxx
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|