Add a get and queue helper work function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
diff --git a/cgminer.c b/cgminer.c
index 62a4789..00e358d 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -6497,6 +6497,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. */
@@ -6507,7 +6514,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);
@@ -6515,6 +6522,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.
diff --git a/miner.h b/miner.h
index 2b0a173..ebbfa00 100644
--- a/miner.h
+++ b/miner.h
@@ -1512,7 +1512,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);