ultimatepp/bazaar/Uniq/Uniq.h
micio d34ec74143 Bazaar/Uniq : fixed stray pipe handling by a crashed main instance
git-svn-id: svn://ultimatepp.org/upp/trunk@3191 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2011-02-10 20:07:08 +00:00

71 lines
1.1 KiB
C++

#ifndef _Uniq_Uniq_h
#define _Uniq_Uniq_h
#include <CtrlLib/CtrlLib.h>
NAMESPACE_UPP
class Uniq
{
private:
// flag indicating we're inside first instance
bool isFirstInstance;
// path of named pipe
String pipePath;
#ifdef flagMT
Thread pollThread;
#endif
#ifdef PLATFORM_POSIX
// lock file to test for pipe existence
String lockPath;
int lockFile;
// send command line to callback handler
bool SendCmdLine(int pipe);
// polling callback -- either threaded or
// run by timed callback
void pollCb(void);
#else
HANDLE pipe;
OVERLAPPED overlapped;
HANDLE event;
// send command line to callback handler
bool SendCmdLine(void);
// polling callback -- either threaded or
// run by timed callback
void pollCb(void);
#endif
protected:
public:
typedef Uniq CLASSNAME;
// callback called when another app instance is run
Callback1<Vector<String> const &> WhenInstance;
Uniq();
~Uniq();
// checks whether we're inside main instance
bool IsFirstInstance(void) { return isFirstInstance; }
operator bool() { return isFirstInstance; }
};
END_UPP_NAMESPACE
#endif