Affinity
Go to the documentation of this file.
/* -*-c++-*- OpenThreads library, Copyright (C) 2016 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
//
// Affinity - C++ Affinity class
// ~~~~~~~~
//
#ifndef _OPENTHREADS_AFFINITY_
#define _OPENTHREADS_AFFINITY_
#include <set>
#include <OpenThreads/Mutex>
namespace OpenThreads {
class Affinity
{
public:
Affinity() {}
Affinity(unsigned int cpuNumber) { activeCPUs.insert(cpuNumber); }
Affinity(unsigned int cpuNumber, unsigned int cpuCount) { while(cpuCount>0) { activeCPUs.insert(cpuNumber++); --cpuCount; } }
Affinity(const Affinity& rhs) : activeCPUs(rhs.activeCPUs) {}
Affinity& operator = (const Affinity& rhs) { if (&rhs!=this) { activeCPUs = rhs.activeCPUs; } return *this; }
void add(unsigned int cpuNmber) { activeCPUs.insert(cpuNmber); }
void remove(unsigned int cpuNmber) { activeCPUs.erase(cpuNmber); }
operator bool () const { return !activeCPUs.empty(); }
typedef std::set<unsigned int> ActiveCPUs;
ActiveCPUs activeCPUs;
};
}
#endif // !_OPENTHREADS_THREAD_
Mutex
OpenThreads::Affinity::add
void add(unsigned int cpuNmber)
Definition Affinity:49
OpenThreads::Affinity::Affinity
Affinity(unsigned int cpuNumber)
Definition Affinity:39
OpenThreads::Affinity::Affinity
Affinity()
Definition Affinity:37
OpenThreads::Affinity::operator=
Affinity & operator=(const Affinity &rhs)
Definition Affinity:45
OpenThreads::Affinity::activeCPUs
ActiveCPUs activeCPUs
Definition Affinity:60
OpenThreads::Affinity::ActiveCPUs
std::set< unsigned int > ActiveCPUs
Definition Affinity:57
OpenThreads::Affinity::Affinity
Affinity(unsigned int cpuNumber, unsigned int cpuCount)
Definition Affinity:41
OpenThreads::Affinity::remove
void remove(unsigned int cpuNmber)
Definition Affinity:52
OpenThreads::Affinity::Affinity
Affinity(const Affinity &rhs)
Definition Affinity:43
OpenThreads
Definition Affinity:26