Click here to Skip to main content
14,367,061 members

Manish K. Agarwal - Professional Profile



Summary

LinkedIn      Blog RSS
24,677
Author
795
Authority
111
Debator
55
Editor
14
Enquirer
1,969
Organiser
1,962
Participant
Working with Oracle. Using C/C++, VC++, MFC, STL, C#, Java etc. on various platform like Windows, Unix, Macintosh etc. from last 13+ years to convert various type of requirements into running software components. My core expertise is multithreaded desktop product and large scale enterprises software development.

Groups

Below is the list of groups in which the member is participating

CodeProject Advisors
Publisher CodeProject
Canada Canada
The CodeProject Advisors group is comprised of CodeProject members specifically chosen to advise the CodeProject on new products related to helping the community answer technical questions. This group participates in beta testing and feedback of products designed to help connect members with experts.
Group type: Collaborative Group
This member has Member status in this group

28 members

Reputation

For more information on Reputation please see the FAQ.

Privileges

Members need to achieve at least one of the given member levels in the given reputation categories in order to perform a given action. For example, to store personal files in your account area you will need to achieve Platinum level in either the Author or Authority category. The "If Owner" column means that owners of an item automatically have the privilege. The member types column lists member types who gain the privilege regardless of their reputation level.

ActionAuthorAuthorityDebatorEditorEnquirerOrganiserParticipantIf OwnerMember Types
Have no restrictions on voting frequencysilversilversilversilverAdmin
Bypass spam checks when posting contentsilversilversilversilversilversilvergoldSitebuilder, Subeditor, Mentor, Protector, Editor, Staff, Admin
Store personal files in your account areaplatinumplatinumSitebuilder, Subeditor, Supporter, Editor, Staff
Have live hyperlinks in your profilebronzebronzebronzebronzebronzebronzesilverSubeditor, Protector, Editor, Staff, Admin
Have the ability to include a biography in your profilebronzebronzebronzebronzebronzebronzesilverSubeditor, Protector, Editor, Staff, Admin
Edit a Question in Q&AsilversilversilversilverYesSubeditor, Protector, Editor, Admin
Edit an Answer in Q&AsilversilversilversilverYesSubeditor, Protector, Editor, Admin
Delete a Question in Q&AYesSubeditor, Protector, Editor, Admin
Delete an Answer in Q&AYesSubeditor, Protector, Editor, Admin
Report an ArticlesilversilversilversilverSubeditor, Mentor, Protector, Editor, Staff, Admin
Approve/Disapprove a pending ArticlegoldgoldgoldgoldSubeditor, Mentor, Protector, Editor, Staff, Admin
Edit other members' articlesSubeditor, Protector, Editor, Admin
Create an article without requiring moderationplatinumSubeditor, Mentor, Protector, Editor, Staff, Admin
Approve/Disapprove a pending QuestionProtector, Admin
Approve/Disapprove a pending AnswerProtector, Admin
Report a forum messagesilversilverbronzeProtector, Editor, Admin
Approve/Disapprove a pending Forum MessageProtector, Admin
Create a new tagsilversilversilversilverAdmin
Modify a tagsilversilversilversilverAdmin

Actions with a green tick can be performed by this member.


 
GeneralSQL date Format expression Pin
Manish K. Agarwal17-Feb-14 3:26
memberManish K. Agarwal17-Feb-14 3:26 
GeneralJava RegEx to Normalize OS File Separator Char Pin
Manish K. Agarwal17-Feb-14 3:14
memberManish K. Agarwal17-Feb-14 3:14 
Generallocale setting Pin
Manish K. Agarwal3-Nov-10 21:53
memberManish K. Agarwal3-Nov-10 21:53 
GeneralWildcard pattern matching Pin
Manish K. Agarwal8-Jul-10 23:05
memberManish K. Agarwal8-Jul-10 23:05 
GeneralRemote Debugging: Quick Steps Pin
Manish K. Agarwal19-Jun-09 2:07
memberManish K. Agarwal19-Jun-09 2:07 
GeneralRe: Remote Debugging: Quick Steps Pin
TejaSingh8-Jul-09 21:05
memberTejaSingh8-Jul-09 21:05 
GeneralAnother C++ Singleton pattern implementation Pin
Manish K. Agarwal7-Apr-09 20:21
memberManish K. Agarwal7-Apr-09 20:21 
Generally I have seen that for singleton implementation, we declare a static pointer mSingletonP and static method GetInstance(). Inside GetInstance(), we check if mSingletonP is NULL, allocate it using new and return the pointer otherwise if it is already allocated simply return the pointer. Typically we implement like this:

class MySingleton
{
public:
	static MySingleton *GetInstance(){
		if (mMySingletonP == NULL) {
			mMySingletonP = new MySingleton;
		}

		return mMySingletonP;
	}

private:
	MySingleton(){
	}

	MySingleton(const MySingleton & ){
	}

	MySingleton & operator=(const MySingleton & ) {
		// Wrong but we just want a private implementation
		// We simply want no one call this.
		return *((MySingleton *)NULL);
	}

	~MySingleton(){
	}

	static MySingleton *mMySingletonP;

};

Further if we want that at the end destructor must invoke, we use atexit(), C Run Time library function and register some function which will take care of delete mMySingltonP.

Recently I have a seen a nice implementation of Singleton. This implementation is good if want to invoke destructor without using atexit. This is not thread safe and this is based on a static keyword. Implementation is as below:

class Singleton
{
public:
	static Singleton &GetInstance(){
		static Singleton instance;

		return instance;
	}

private:
	Singleton(){
	}

	Singleton(const Singleton & ){
	}

	Singleton & operator=(const Singleton & ) {
		// We simply want no one call this.
		return *this;
	}

	~Singleton(){
	}

};


Above is the best implementation for non thread safe singleton and below is the best implementation for thread safe singleton.

For thread safe implementation of GetInstance() we use double NULL checking and locking in our traditional singleton implementation i.e.

static MySingleton *GetInstance() {

     if (mMySingletonP == NULL) {
           // Aquire a lock here
           if (mMySingletonP == NULL) {
                mMySingletonP = new MySingleton;
           }
           // relase lock here
     }

     return mMySingletonP;
}

Please share your views on the same.

Usage:
int _tmain(int argc, _TCHAR* argv[])
{
	int nTmp1 = 10;
	Singleton &firstRef = Singleton::GetInstance();

	Singleton &otherRef = Singleton::GetInstance();

	return 0;
}

Manish Agarwal
manish.k.agarwal @ gmail DOT com


Generalsprintf_s on UNIX / Mac Pin
Manish K. Agarwal21-Nov-08 0:42
memberManish K. Agarwal21-Nov-08 0:42 
GeneralActivation Codes Pin
Manish K. Agarwal24-Nov-05 19:55
memberManish K. Agarwal24-Nov-05 19:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.