Browse Source

Add a get_queued function for devices to use to retrieve work items from the queued hashtable.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
fce5434975
  1. 21
      cgminer.c
  2. 1
      miner.h

21
cgminer.c

@ -5619,6 +5619,27 @@ static void fill_queue(struct thr_info *mythr, struct cgpu_info *cgpu, struct de
} while (!drv->queue_full(cgpu)); } while (!drv->queue_full(cgpu));
} }
/* This function is for retrieving one work item from the queued hashtable of
* available work items that are not yet physically on a device (which is
* flagged with the work->queued bool). Code using this function must be able
* to handle NULL as a return which implies there is no work available. */
struct work *get_queued(struct cgpu_info *cgpu)
{
struct work *work, *tmp, *ret = NULL;
wr_lock(&cgpu->qlock);
HASH_ITER(hh, cgpu->queued_work, work, tmp) {
if (!work->queued) {
work->queued = true;
ret = work;
break;
}
}
wr_unlock(&cgpu->qlock);
return ret;
}
/* This function should be used by queued device drivers when they're sure /* This function should be used by queued device drivers when they're sure
* the work struct is no longer in use. */ * the work struct is no longer in use. */
void work_completed(struct cgpu_info *cgpu, struct work *work) void work_completed(struct cgpu_info *cgpu, struct work *work)

1
miner.h

@ -1104,6 +1104,7 @@ struct modminer_fpga_state {
extern void get_datestamp(char *, struct timeval *); extern void get_datestamp(char *, struct timeval *);
extern void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce); extern void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
extern struct work *get_queued(struct cgpu_info *cgpu);
extern void work_completed(struct cgpu_info *cgpu, struct work *work); extern void work_completed(struct cgpu_info *cgpu, struct work *work);
extern void hash_queued_work(struct thr_info *mythr); extern void hash_queued_work(struct thr_info *mythr);
extern void tailsprintf(char *f, const char *fmt, ...); extern void tailsprintf(char *f, const char *fmt, ...);

Loading…
Cancel
Save