NOTES TO SELF

atomic struct mthread_status {
  unsigned int area_covered 
  bool undevidable
  bool searching
  bool division_syn
  bool division_ack
  bool division_syn_ack
}


Thread finishes its job.
1: set "searching" local atomic struct to true
2: for each thread:

  if done=true; exit

  if searing, division_syn, division_ack, undevidable: go to next
    if all seem to be searching, set global done=true

  if not: continue below

3: record area_covered in own array, if more threads proceed to next, else continue below

4: pick thread with largest area_covered:
5: if division_syn or division_ack or searching or undevidable, go to next

5: set division_syn to true, wait for division_ack
6: divide(): copy over half of x/y, copy divisions, check and set undevidable, start to do work

thread is working.
1: 
for y:
  update area_covered
  check division_syn
  if true: 2 inline here
  for x:
    do some math stuff here
searching = true, "if thread finishes its job" inline here.


2: 
set division_ack
wait for division_syn_ack
check and set undevidable
// there should be no conflict with updating variable y is dependent on,
// as it's always more then current, and test will be accurate next loop.


thread is starting.
1: 
for y:
  update area_covered
  check division_syn
  if true: 2 inline here
  for x:
    do some math stuff here
searching = true, "if thread finishes its job" inline here.


PREFORMANCE:
without tasks helping eachother (commit c30fc7596810f7033dfd9a7452c808153bd2e14a):

const uint32_t WIDTH = 1920;
const uint32_t HEIGHT = 1080;
const int JOBS = 6; //test uneven stuff
const std::complex<double> b_min (-0.7463-0.005, 0.1102-0.005);
const std::complex<double> b_max (-0.7463+0.005, 0.1102+0.005);
#define MAX_ITER 1000 
#define INF_CUTOFF 256
#define COLOR_RAMP 100

/usr/bin/time -f '%p' -p ./mandelbrot

real 36.41
user 105.00
sys 0.02

real 36.38
user 104.98
sys 0.02

real 36.32
user 105.00
sys 0.05

With tasks helping eachother: (commit 3663966b88681f44ec8939e39e33ef922227b7a7):

real 19.21
user 111.70
sys 0.03

real 19.29
user 111.61
sys 0.02

real 19.30
user 111.84
sys 0.02


//CONTENDOR_HI REPLACEMENT - 50000 iterations
//const complex<double> DEFAULT_B_MIN (-0.74364386269 - 0.00000003000, 0.13182590271 - 0.00000003000);
//const complex<double> DEFAULT_B_MAX (-0.74364386269 + 0.00000003000, 0.13182590271 + 0.00000003000);

//CONTENDOR_ZOOM- 50000 iterations
//const complex<double> DEFAULT_B_MIN (-0.74364386269 - 0.00000001000, 0.13182590271 - 0.00000001000);
//const complex<double> DEFAULT_B_MAX (-0.74364386269 + 0.00000001000, 0.13182590271 + 0.00000001000);
