|
From: Rich S. <rd...@ri...> - 2006-10-18 23:42:07
|
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
>
|