Shared db pool

Alex Khmara alex.khmara at gmail.com
Mon Mar 18 15:28:55 PDT 2013


Thanks, Benjamin.

I'll try to somehow disable copying. At the end I can change struct to 
scoped class and write custom opAssign for it...
Well, I need to play with it.

Thanks you again.

On Mon, 18 Mar 2013 22:05:51 +0100, Benjamin Thaut wrote:

> Am 18.03.2013 20:55, schrieb Alex Khmara:
>> This compiles (and simplified example wit big sleeps in get and debug 
output seems to work correctly),
>> but I am not sure about thread-safety.
> 
> Looks thread safe for me.
> 
>>
>> If after that I will have no no shared-related overhead in call to 
Mysql methods than
>> things are good - pool will not give Mysql instance to second thread 
until it will be relased by first thread.
> 
> The only problem you may run into, is that the destructor of PoolRef 
> might gets called multiple times if you are not really carefull with 
> temporary variables. Ideal would be a way to disallow copying of the 
> struct and only allow moving it, last I checked this was not possible 
in 
> D. Because when you do @disable this(this) it will also disallow moving 
> the struct. Although you could try with the current version.
> 
> Kind Regards
> Benjamin Thaut



More information about the Digitalmars-d-learn mailing list