octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Eliminating Singleton Objects


From: John W. Eaton
Subject: Re: Eliminating Singleton Objects
Date: Tue, 2 May 2017 15:26:20 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

On 04/30/2017 11:28 PM, Rik wrote:

It's true.  I don't think register pressure is going to develop at 2 or 3
function parameters.  I thought we might already be at the 4-5 parameter
range in which case another could make a difference.

If the compiler is no longer doing initialization of the singleton, is this
the cause of certain data race bugs between the interpreter and the GUI
thread?  Bug #50880 and #50396 both seem to be caused by the GUI looking
for interpreter static variables that have not been initialized in time.

With the singleton idiom, there is no way for the object to be used before it is initialized. That's the one nice thing about singletons. But, with multiple threads, I suppose it's possible that the initialization code could be called from two threads simultaneously, and that will certainly cause trouble.

Also, if the pointer to the interpreter really is used all over the code
base, maybe it does make sense to have it be a global?  I know it is
generally frowned upon, but it might actually be simpler then re-working
the API to pass the pointer through to all functions.

For now it will have to remain global because we need a way to access the objects like the symbol table and the load path that are singletons. But I would eventually like to eliminate the global because I would like to be able to allow a single program to contain multiple interpreter objects that are completely independent of one another. So all data for an interpreter instance would need to be owned by the interpreter object. Maybe that's an impossible goal, but for now I'd like to aim for it.

jwe




reply via email to

[Prev in Thread] Current Thread [Next in Thread]