|
#ifndef __UTILITY_HELPER__H
#define __UTILITY_HELPER__H
#include "stdafx.h"
namespace LockFree
{
// disallow copying objects
template <class T>
class NonCopyable
{
protected:
NonCopyable () {}
~NonCopyable () {} /// Protected non-virtual destructor
private:
NonCopyable (const NonCopyable &);
T & operator = (const T &);
};
//
class tSysInfo
{
public:
tSysInfo()
{
GetSystemInfo( &sysinfo );
}
unsigned int GetNumberofProcessors()
{
return sysinfo.dwNumberOfProcessors;
}
private:
SYSTEM_INFO sysinfo;
};
//
class Helper : private NonCopyable<Helper>
{
public:
// Get the number of CPU on this machine
static unsigned int GetNumberOfProcessors()
{
static tSysInfo Sysinfo;
return Sysinfo.GetNumberofProcessors();
}
private:
Helper();
};
//
};
#endif // __UTILITY_HELPER__H
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Studied MSc Network and Parallel computing from Reading University, UK. I was always interested in IT. Previously worked in Network-Security, Games Development, Satellite Communications and now in Financial Services industry. After work, usually time spent with my son. Love playing cricket, badminton - though not happening much on sports these days. OK, enough about me.
Email: sameer_87@hotmail.com