Browse Source

Add a get and queue helper work function.

port-ckolivas
ckolivas 11 years ago committed by Noel Maersk
parent
commit
8592226ad2
  1. 3
      miner.h
  2. 25
      sgminer.c

3
miner.h

@ -1385,7 +1385,10 @@ extern bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce @@ -1385,7 +1385,10 @@ extern bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce
extern bool submit_noffset_nonce(struct thr_info *thr, struct work *work, uint32_t nonce,
int noffset);
extern struct work *get_work(struct thr_info *thr, const int thr_id);
extern void __add_queued(struct cgpu_info *cgpu, struct work *work);
extern struct work *get_queued(struct cgpu_info *cgpu);
extern void add_queued(struct cgpu_info *cgpu, struct work *work);
extern struct work *get_queue_work(struct thr_info *thr, struct cgpu_info *cgpu, int thr_id);
extern struct work *__find_work_bymidstate(struct work *que, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
extern struct work *find_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
extern struct work *clone_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);

25
sgminer.c

@ -6310,6 +6310,13 @@ static void fill_queue(struct thr_info *mythr, struct cgpu_info *cgpu, struct de @@ -6310,6 +6310,13 @@ static void fill_queue(struct thr_info *mythr, struct cgpu_info *cgpu, struct de
} while (!drv->queue_full(cgpu));
}
/* Add a work item to a cgpu's queued hashlist */
void __add_queued(struct cgpu_info *cgpu, struct work *work)
{
cgpu->queued_count++;
HASH_ADD_INT(cgpu->queued_work, id, work);
}
/* This function is for retrieving one work item from the unqueued pointer and
* adding it to the hashtable of queued work. Code using this function must be
* able to handle NULL as a return which implies there is no work available. */
@ -6320,7 +6327,7 @@ struct work *get_queued(struct cgpu_info *cgpu) @@ -6320,7 +6327,7 @@ struct work *get_queued(struct cgpu_info *cgpu)
wr_lock(&cgpu->qlock);
if (cgpu->unqueued_work) {
work = cgpu->unqueued_work;
HASH_ADD_INT(cgpu->queued_work, id, work);
__add_queued(cgpu, work);
cgpu->unqueued_work = NULL;
}
wr_unlock(&cgpu->qlock);
@ -6328,6 +6335,22 @@ struct work *get_queued(struct cgpu_info *cgpu) @@ -6328,6 +6335,22 @@ struct work *get_queued(struct cgpu_info *cgpu)
return work;
}
void add_queued(struct cgpu_info *cgpu, struct work *work)
{
wr_lock(&cgpu->qlock);
__add_queued(cgpu, work);
wr_unlock(&cgpu->qlock);
}
/* Get fresh work and add it to cgpu's queued hashlist */
struct work *get_queue_work(struct thr_info *thr, struct cgpu_info *cgpu, int thr_id)
{
struct work *work = get_work(thr, thr_id);
add_queued(cgpu, work);
return work;
}
/* This function is for finding an already queued work item in the
* given que hashtable. Code using this function must be able
* to handle NULL as a return which implies there is no matching work.

Loading…
Cancel
Save