/usr/include/primesieve/ParallelPrimeSieve.hpp is in libprimesieve6-dev-common 5.6.0+ds-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | ///
/// @file ParallelPrimeSieve.hpp
/// @brief The ParallelPrimeSieve class provides an easy API for
/// multi-threaded prime sieving.
///
/// Copyright (C) 2014 Kim Walisch, <kim.walisch@gmail.com>
///
/// This file is distributed under the BSD License. See the COPYING
/// file in the top level directory.
///
#ifndef PARALLELPRIMESIEVE_HPP
#define PARALLELPRIMESIEVE_HPP
#include "PrimeSieve.hpp"
#include <stdint.h>
namespace primesieve {
/// ParallelPrimeSieve sieves primes in parallel, it is
/// derived from PrimeSieve so it has the same API.
/// Please refer to doc/EXAMPLES for more information.
///
class ParallelPrimeSieve : public PrimeSieve
{
public:
/// Used for inter-process communication with the
/// primesieve GUI application.
struct SharedMemory
{
uint64_t start;
uint64_t stop;
uint64_t counts[6];
double status;
double seconds;
int flags;
int sieveSize;
int threads;
};
ParallelPrimeSieve();
virtual ~ParallelPrimeSieve() { }
void init(SharedMemory&);
static int getMaxThreads();
int getNumThreads() const;
void setNumThreads(int numThreads);
using PrimeSieve::sieve;
virtual void sieve();
private:
enum { IDEAL_NUM_THREADS = -1 };
void* lock_;
SharedMemory* shm_;
int numThreads_;
bool tooMany(int) const;
int idealNumThreads() const;
uint64_t getThreadInterval(int) const;
uint64_t align(uint64_t) const;
template <typename T> T getLock() { return static_cast<T>(lock_); }
virtual double getWallTime() const;
virtual void setLock();
virtual void unsetLock();
virtual bool updateStatus(uint64_t, bool);
};
} // namespace primesieve
#endif
|