Browse Source

Provide a variant of find_work_bymidstate that returns a clone of the found work.

nfactor-troky
Con Kolivas 11 years ago
parent
commit
98e338cc52
  1. 13
      cgminer.c
  2. 1
      miner.h

13
cgminer.c

@ -6060,6 +6060,19 @@ struct work *find_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, @@ -6060,6 +6060,19 @@ struct work *find_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate,
return ret;
}
struct work *clone_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen)
{
struct work *work, *ret = NULL;
rd_lock(&cgpu->qlock);
work = __find_work_bymidstate(cgpu->queued_work, midstate, midstatelen, data, offset, datalen);
if (work)
ret = copy_work(work);
rd_unlock(&cgpu->qlock);
return ret;
}
/* This function should be used by queued device drivers when they're sure
* the work struct is no longer in use. */
void work_completed(struct cgpu_info *cgpu, struct work *work)

1
miner.h

@ -1333,6 +1333,7 @@ extern bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce @@ -1333,6 +1333,7 @@ extern bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce
extern struct work *get_queued(struct cgpu_info *cgpu);
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);
extern void work_completed(struct cgpu_info *cgpu, struct work *work);
extern void hash_queued_work(struct thr_info *mythr);
extern void _wlog(const char *str);

Loading…
Cancel
Save