+ Reply to Thread
Results 1 to 3 of 3

Thread: write thread safe singleton class

  1. #1
    Surfer is offline Senior Member
    Join Date
    Mar 2010
    Posts
    321

    write thread safe singleton class

    write thread safe singleton class.

  2. #2
    Surfer is offline Senior Member
    Join Date
    Mar 2010
    Posts
    321
    Code:
    class CSingleton
    {
        private:
            CSingleton *mInstance;
            ...
        public:
            Static Csingleton* getInstance()
            {
                AcquireLock();
                if(mInstance==NULL)
                    mInstance=new CSingleton();
                ReleaseLock();
                return mInstance;
            }
    }
    AcquireLock/ReleaseLock can be implemented using various different lock semantics.

  3. #3
    Krazy Guest

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to delete object in Singleton class
    By Surfer in forum Bloomberg
    Replies: 0
    Last Post: 26th May 2010, 23:30
  2. Implement a thread-safe class
    By Surfer in forum Linux System Programming
    Replies: 0
    Last Post: 24th March 2010, 11:58
  3. What is Singleton Class?
    By TopGun in forum Amazon
    Replies: 2
    Last Post: 28th December 2009, 11:55

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts