Skip to content

Instantly share code, notes, and snippets.

@egraldlo
Created September 17, 2014 01:52
Show Gist options
  • Save egraldlo/2eb17cb0cf3179099284 to your computer and use it in GitHub Desktop.
Save egraldlo/2eb17cb0cf3179099284 to your computer and use it in GitHub Desktop.
single instance
/*
* m_executor.h
*
* Created on: 2014-8-30
* Author: casa
*/
#ifndef M_EXECUTOR_H_
#define M_EXECUTOR_H_
class Executor {
public:
Executor();
virtual ~Executor();
static Executor *getInstance();
private:
static Executor *executor_;
};
#endif /* M_EXECUTOR_H_ */
/*
* m_executor.cpp
*
* Created on: 2014-8-30
* Author: casa
*/
#include "m_executor.h"
Executor* Executor::executor_=0;
Executor::Executor() {
// TODO Auto-generated constructor stub
}
Executor::~Executor() {
// TODO Auto-generated destructor stub
}
Executor* Executor::getInstance() {
if(executor_==0) {
executor_=new Executor();
}
return executor_;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment