Click here to Skip to main content
15,880,651 members

Manish K. Agarwal - Professional Profile



Summary

LinkedIn      Blog RSS
27,236
Author
809
Authority
111
Debator
55
Editor
16
Enquirer
2,825
Organiser
2,540
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

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.
This is a Collaborative Group
This member has Member status in this group

28 members

Reputation

Weekly Data. Recent events may not appear immediately. For 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 frequencysilversilversilversilver
Bypass spam checks when posting contentsilversilversilversilversilversilvergoldSubEditor, Mentor, Protector, Editor
Store personal files in your account areaplatinumplatinumSubEditor, Editor
Have live hyperlinks in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Have the ability to include a biography in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Edit a Question in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Edit an Answer in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Delete a Question in Q&AYesSubEditor, Protector, Editor
Delete an Answer in Q&AYesSubEditor, Protector, Editor
Report an ArticlesilversilversilversilverSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending ArticlegoldgoldgoldgoldSubEditor, Mentor, Protector, Editor
Edit other members' articlesSubEditor, Protector, Editor
Create an article without requiring moderationplatinumSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending QuestionProtector
Approve/Disapprove a pending AnswerProtector
Report a forum messagesilversilverbronzeProtector, Editor
Approve/Disapprove a pending Forum MessageProtector
Have the ability to send direct emails to members in the forumsProtector
Create a new tagsilversilversilversilver
Modify a tagsilversilversilversilver

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


 
GeneralSQL date Format expression Pin
Manish K. Agarwal17-Feb-14 2:26
Manish K. Agarwal17-Feb-14 2:26 
GeneralJava RegEx to Normalize OS File Separator Char Pin
Manish K. Agarwal17-Feb-14 2:14
Manish K. Agarwal17-Feb-14 2:14 
Generallocale setting Pin
Manish K. Agarwal3-Nov-10 20:53
Manish K. Agarwal3-Nov-10 20:53 
GeneralWildcard pattern matching Pin
Manish K. Agarwal8-Jul-10 22:05
Manish K. Agarwal8-Jul-10 22:05 
GeneralRemote Debugging: Quick Steps Pin
Manish K. Agarwal19-Jun-09 1:07
Manish K. Agarwal19-Jun-09 1:07 
GeneralRe: Remote Debugging: Quick Steps Pin
TejaSingh8-Jul-09 20:05
TejaSingh8-Jul-09 20:05 
GeneralAnother C++ Singleton pattern implementation Pin
Manish K. Agarwal7-Apr-09 19:21
Manish K. Agarwal7-Apr-09 19: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:

C++
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:

C++
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.

C++
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:
C++
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. Agarwal20-Nov-08 23:42
Manish K. Agarwal20-Nov-08 23:42 
GeneralActivation Codes Pin
Manish K. Agarwal24-Nov-05 18:55
Manish K. Agarwal24-Nov-05 18: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.