Hi,
I am intrigued as to how singletons work in Google App Engine (or any distributed server environment). Given your application can be running in multiple processes (on multiple machines) at once, and requests can get routed all off the place, what actually happens under the hood when an app does something like: 'CacheManager.getInst...
I'm writing my first iPhone application and I'm having trouble switching views. I have 2 views and a reference to each in the AppDelegate (an instance of UIApplicationDelegate). I create instances of both in the applicationDidFinishLaunching and immediately show the first view. This works fine.
The problem is the reference to the o...
I started to develop my singleton class but I have a problem.
What I want to do is have a search objects containing the values of the search form that I could use in several views.
I want to have the ability to get the singleton in any view in order to perform the search or build the search form.
So I have a set of values with a boolean ...
I better explain the question with an example.
I have an Interface Model which can be used to access data.
There can be different implementations of Model which can represent the data in various format say XMl , txt format etc. Model is not concerned with the formats.
Lets say one such implementation is myxmlModel.
Now i want to force m...
Hi,
When we want deploy Web Application should we use singleton Object or use Static instead of?
what is the bottleneck for use each of them?
I should know about Memory Problem , Concurrency problem and ... .
P.S: what happen for the class that was just readable (should use static or Singleton)
P.S 2: what happen for the class that wa...
Hi,
I'm just starting my journey into OOP - and I'm currently trying to roll my own MVC - purely for learning purposes. I'm working through a tutorial in the Apress PHP-Objects Patterns Practice book. I've created a registry singleton object using the private __construct/__clone technique:
class Registry
{
private static $instance;
...
I would like to create a singleton class that is instantiated once in each thread where it is used. I would like to store the instance pointers in TLS slots. I have come up with the following solution but I am not sure whether there are any special considerations with multithreaded access to the singelton factory when thread local storag...
For applications of any size, what are the drawbacks of using a Context.Current pattern? (i.e. "Current" is a shared/static property of a "Context" class that instantiates itself the first time it's used)
Any advantage of using this pattern over just shared / static classes/methods?
I'm asking in the context of .NET, although I guess i...
So I've been programming in C# for the last 6 years or so and now I'm getting my feet wet with VB.net.
The code base I'm working with uses some modules. To me the module looks a lot like a singleton. Only one exists; it can be called anywhere inside the namespace.
Is there something I'm missing here? Does VB not support the normal wa...
I am working on a project where I have lots of classes referring to my GUI (mainly the panels but sometimes the frame itself). So I was thinking that instead of passing the frame as an argument to every constructor and create getters in each class, I would make a singleton instance of the JFrame so all the classes get access to it instea...
I've been trying to implement a singleton for shared data in an iPhone app, and I've used both the macro found here:
link text
and I've tried transplanting the code from the macro to straight .h/.m files and I can Build and Debug just fine, but once I try to run instruments I get an immediate crash with no helpful information (before t...
What is a good way to implement a singleton that will be restricted only to the thread that seeks its instance? Is there a thread id or something that I can use to do that? I'm using Carbon threading API but will have to implement this on windows and pure POSIX later too, so any technique is appreciated.
...
As Scott Meyers and Andrei Alexandrescu outlined in this article the simple try to implement the double-check locking implementation is unsafe in C++ specifically and in general on multi-processor systems without using memory barriers.
I was thinking a little bit about that and came to a solution that avoids using memory barriers and sh...
Just a quick question. I understand that Singleton patterns can be extended and that inheritance is applied. I was just wondering if I called a base class and then a extended class is there additional overhead than if I just called the extended class by itself?
...
Hi,
I want to display an Flex component in several different places through out the application. And it should be the same instance of the component, but not the copies.
So I think of making the Component as an Singleton.
But the problem is :
when I do something like this :
var vb1: VBox = new VBox();
var vb2: VBox = new V...
Hi,
I know this must be an age-old, tired question, but I cant seem to find anything thru my trusty friend (aka Google).
I have a .net 3.5 c# winforms app, that presents a user with a login form on application startup. After a successful login, I want to run off to the DB, pull in some user-specific data and hold them (in properties) ...
Hello,
Jon Skeet's excellent article at http://www.yoda.arachsys.com/csharp/singleton.html and other articles I've read make it clear that that double-check locking doesn't work in both C# and Java unless one explicitly marks the instance as "volatile." If you don't, the check of comparing it to null could possibly return false even tho...
I've a lot of (abstract) factories and they're usually implemented as singletons.
Usually for the convenience of not having to pass them through layers who really have no business with using or knowing these factories.
Most of the times I only need to make a decision at startup of which factory implementation the rest of the code prog...
public class BaseFoo
{
private string param;
public BaseFoo(string param)
{
this.param = param;
}
}
public sealed class SingletonFoo : BaseFoo
{
static readonly SingletonFoo instance = new SingletonFoo();
static SingletonFoo()
{
}
public static SingletonFoo Instance
{
get
...
What happens if we serialize a static class? Can more than one instance of the static class be created if we serialize it?
[Serializable]
public static class MyClass
{
public static MyClass()
{
}
public static bool IsTrue()
{
return true;
}
}
Suppose I XmlSerialize the object to a XML file, and at a la...