|
From: nilesh j. <nil...@pa...> - 2006-10-19 15:07:42
|
Hi Rich,
Thanks a lot for your help. I think
this might help.
Actually i wanted to implement multithreading
in two ways. One is i wanted to remove the loki
locks since i didnot want to rewrite the locks
since i already had them in place.This meant i had
to move the volatile declaration away from
ObjectLevelLockable and place them in singleton.
And second was i rewrote the code in
the place given by Loki. In either cases it
gave me errors.
I will try your suggestion and revert back in case
of errors.
Thanks a lot once again.
Nilesh Joshi
-----Original Message-----
From: Rich Sposato [mailto:rd...@ri...]
Sent: Thursday, October 19, 2006 5:12 AM
To: nil...@pa...; lok...@li...
Subject: Re: Help Required for Loki's small object
Hi Nilesh,
I recommend defining T as "volatile T" when using
SingletonHolder with a multi-threaded model.
The function:
inline T & SingletonHolder< T, CreationPolicy,
LifetimePolicy, ThreadingModel, MutexPolicy >
::Instance()
will return a reference to a volatile T if you use a
multi-threaded model and if you declare your singleton
like this:
::Loki::SingletonHolder< volatile T, whatever,
whatever, ::Loki::ObjectLevelLockable,
whatever >;
If you define it like this:
::Loki::SingletonHolder< T, whatever,
whatever, ::Loki::ObjectLevelLockable,
whatever >;
without the "volatile T" it will not return a
reference
with the proper volatile qualification.
Meanwhile, I found another bug with SmallObject and
ObjectLevelLockable while studying this bug. I will
have look at that bug.
Cheers,
Rich
--- Richard Sposato <rd...@ri...> wrote:
> Hi Nilesh,
>
> Can you tell us exactly what error messages you get
> from GCC?
>
> Meanwhile, I'm going to take another look at Loki's
> test projects. I'm
> sure we have several tests which cover the
> singleton, threading, and
> small-object-allocator parts of Loki. You might
> want to take a look at
> those test projects and see if any of them are
> similar enough to how you
> use Loki.
>
> Thanks,
>
> Rich
>
> nilesh joshi wrote:
> > Hi,
> > I am new for using small object allocator.
> > I have ported it on gcc compiler for Motorolla
> processor.
> > It compiles and works fine for single threaded
> option while
> > using singleton.
> > But as soon as i give an option for
> ObjectLevelLockable
> > the GCC compiler start giving errors.
> > This is because for ObjectLevelLockable class,
> Loki makes use
> > of a volatile variable for class Host in object
> > and SingleThreaded doesnot make use of one.
> > This is used to create a pointer instance in
> singleton.h
> > But the singleton implementation for instance()
> doesnot return
> > a volatile reference.
> > Is there a trick that is to be used to remove
> these errors
> > or is it that we have to do manual changes to
> return the
> > volatile reference everytime we use multithreaded
> applications.
> > Awaiting your reply.
> > Thanks in advance,
> > Regards,
> > Nilesh.
>
>
>
-------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support
> web services, security?
> Get stuff done quickly with pre-integrated
> technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1
> based on Apache Geronimo
>
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Loki-lib-general mailing list
> Lok...@li...
>
https://lists.sourceforge.net/lists/listinfo/loki-lib-general
>
http://www.patni.com
World-Wide Partnerships. World-Class Solutions.
_____________________________________________________________________
This e-mail message may contain proprietary, confidential or legally
privileged information for the sole use of the person or entity to
whom this message was originally addressed. Any review, e-transmission
dissemination or other use of or taking of any action in reliance upon
this information by persons or entities other than the intended
recipient is prohibited. If you have received this e-mail in error
kindly delete this e-mail from your records. If it appears that this
mail has been forwarded to you without proper authority, please notify
us immediately at net...@pa... and delete this mail.
_____________________________________________________________________
|