Advertisement
Guest User

Untitled

a guest
Nov 28th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1.    while(retst) {
  2.       if (qpipe.size() == 0) continue;
  3.       pthread_mutex_lock(&self->mr);
  4.       unsigned long n = qpipe.front();
  5.       qpipe.pop();
  6.       pthread_mutex_unlock(&self->mr);
  7.       self->counter++;
  8.       if (prime(n)) self->primes++;
  9.       if (self->counter%1001 == 0) {
  10.          printf("total numbers:%10lu; primes:%11lu; %% of primes:%7.4f\r", self->counter, self->primes, double(self->primes)/self->counter);
  11. ········ fflush(stdout);
  12.       }
  13.    }  
  14.    pthread_testcancel();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement