32 #include <boost/utility.hpp>
57 template <
typename floatType>
64 typedef std::tuple<std::uint8_t, std::uint8_t, std::uint8_t>
colorType;
77 const std::shared_ptr<png::pngFactory>& pngFact ) :
93 for( floatType im{ this->
m_fParams->lowerLeftExtent.imag() };
94 im < this->
m_fParams->upperRightExtent.imag();
101 this->
m_fParams->upperRightExtent.imag() -
102 this->
m_fParams->lowerLeftExtent.imag() )) / 10.0;
103 std::cout <<
"Count to ten:" << std::endl;
106 for( std::uint32_t thr{0}; thr < (this->
m_numThreads); ++thr )
108 std::unique_ptr<std::thread> curThr{
113 this->
m_threads.push_back( std::move(curThr) );
121 []( decltype(*(this->
m_threads.begin()))& thrd ) ->
void
125 std::cout << std::endl;
136 const std::shared_ptr<fractal::fractalParams<floatType>>
m_fParams;
173 floatType curRow{ 0.0 };
174 std::int32_t statNum{ -1 };
186 const std::uint32_t tenth(
187 static_cast<std::uint32_t>(
201 std::cout << statNum << std::flush;
203 for( floatType rl{ this->
m_fParams->lowerLeftExtent.real() };
204 rl < this->
m_fParams->upperRightExtent.real();
210 std::complex<floatType>( rl, curRow ),
212 this->m_fParams->f_prime,
213 this->m_fParams->maxIterations,
214 this->m_fParams->zeroEpsilon };
215 std::uint32_t numIterations{ 0 };
216 const std::complex<floatType> zero{
217 solver.findZero( numIterations ) };
230 std::get<2>(color) );
std::bitset< 10 > m_tenthStatusPrinted
This attribute holds ten booleans. These booleans are set when the corresponding status number has be...
~threadedFractalEngine()
The class destructor.
std::tuple< std::uint8_t, std::uint8_t, std::uint8_t > colorType
This type is used to define variables that hold colors. The standard RGB color definition is used her...
threadedFractalEngine(const std::shared_ptr< fractal::fractalParams< floatType >> &fParams, const std::shared_ptr< png::pngFactory > &pngFact)
This is the constructor that must be used to create instances of this class.
const std::shared_ptr< fractal::fractalParams< floatType > > m_fParams
This attribute holds a pointer to the class instance that contains the parameters used to generate th...
void doFractal(void)
This method is called to compute the given fractal.
std::mutex m_rowQueueGuard
This attribute holds the mutex that guards access to the row queue.
This class splits the work of computing a given fractal amoung several threads.
const std::uint32_t m_numThreads
This attribute holds the number of threads that this instance is to spawn to compute the given fracta...
floatType m_tenthOfRange
This attribute holds a tenth of the imaginary range (that is, a tenth of the rows). This is used in the status count.
std::deque< floatType > m_rowQueue
This attribute is the queue that holds the rows of the fractal yet to be computed.
std::mutex m_pngFactGuard
This attribute holds a mutex used to serialize access to the PNG factory.
This class is a container class for the parameters that are used to generate a fractal.
This class implements Newton's method (the same one from your typical first year calculus class)...
void fractalWorkerThread(void)
This method is the main (top level) method of each of the fractal computation threads.
const std::shared_ptr< png::pngFactory > m_pngFact
This attribute holds a pointer to the factory used to generate the PNG image.
std::vector< std::unique_ptr< std::thread > > m_threads
This attribute holds the thread objects used to compute the given fractal.
threadedFractalEngine()=delete