Browse Source

When popping work, grab cloned work first if possible since original work can be reused to make further clones.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
4f9394be81
  1. 20
      cgminer.c

20
cgminer.c

@ -3834,17 +3834,29 @@ out:
static struct work *hash_pop(const struct timespec *abstime) static struct work *hash_pop(const struct timespec *abstime)
{ {
struct work *work = NULL; struct work *work = NULL, *worka, *workb;
int rc = 0; int rc = 0;
mutex_lock(stgd_lock); mutex_lock(stgd_lock);
while (!getq->frozen && !HASH_COUNT(staged_work) && !rc) while (!getq->frozen && !HASH_COUNT(staged_work) && !rc)
rc = pthread_cond_timedwait(&getq->cond, stgd_lock, abstime); rc = pthread_cond_timedwait(&getq->cond, stgd_lock, abstime);
if (HASH_COUNT(staged_work)) { if (unlikely(!HASH_COUNT(staged_work)))
work = staged_work; goto out_unlock;
HASH_DEL(staged_work, work);
/* Look for cloned work first since original work can be used to
* generate further clones */
HASH_ITER(hh, staged_work, worka, workb) {
if (worka->clone) {
HASH_DEL(staged_work, worka);
work = worka;
goto out_unlock;
}
} }
work = staged_work;
HASH_DEL(staged_work, work);
out_unlock:
mutex_unlock(stgd_lock); mutex_unlock(stgd_lock);
queue_request(NULL, false); queue_request(NULL, false);

Loading…
Cancel
Save