|
|
@@ -226,17 +226,12 @@ pair<bool, int> DualPatternComposer::nextBatch(PerThreadReadBuf& pt) { |
|
|
* Returns pair<bool, int> where bool indicates whether we're
|
|
|
* completely done, and int indicates how many reads were read.
|
|
|
*/
|
|
|
-pair<bool, int> CFilePatternSource::nextBatch(
|
|
|
+pair<bool, int> CFilePatternSource::nextBatchImpl(
|
|
|
PerThreadReadBuf& pt,
|
|
|
- bool batch_a,
|
|
|
- bool lock)
|
|
|
+ bool batch_a)
|
|
|
{
|
|
|
bool done = false;
|
|
|
int nread = 0;
|
|
|
-
|
|
|
- // synchronization at this level because both reading and manipulation of
|
|
|
- // current file pointer have to be protected
|
|
|
- ThreadSafe ts(&mutex, lock);
|
|
|
pt.setReadId(readCnt_);
|
|
|
while(true) { // loop that moves on to next file when needed
|
|
|
do {
|
|
|
@@ -259,6 +254,21 @@ pair<bool, int> CFilePatternSource::nextBatch( |
|
|
return make_pair(done, nread);
|
|
|
}
|
|
|
|
|
|
+pair<bool, int> CFilePatternSource::nextBatch(
|
|
|
+ PerThreadReadBuf& pt,
|
|
|
+ bool batch_a,
|
|
|
+ bool lock)
|
|
|
+{
|
|
|
+ if(lock) {
|
|
|
+ // synchronization at this level because both reading and manipulation of
|
|
|
+ // current file pointer have to be protected
|
|
|
+ ThreadSafe ts(&mutex);
|
|
|
+ return nextBatchImpl(pt, batch_a);
|
|
|
+ } else {
|
|
|
+ return nextBatchImpl(pt, batch_a);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Open the next file in the list of input files.
|
|
|
*/
|
|
|
@@ -366,12 +376,10 @@ VectorPatternSource::VectorPatternSource( |
|
|
* in the contsructor. This essentially modifies the pt as though we read
|
|
|
* in some number of patterns.
|
|
|
*/
|
|
|
-pair<bool, int> VectorPatternSource::nextBatch(
|
|
|
+pair<bool, int> VectorPatternSource::nextBatchImpl(
|
|
|
PerThreadReadBuf& pt,
|
|
|
- bool batch_a,
|
|
|
- bool lock)
|
|
|
+ bool batch_a)
|
|
|
{
|
|
|
- ThreadSafe ts(&mutex, lock);
|
|
|
pt.setReadId(cur_);
|
|
|
vector<Read>& readbuf = batch_a ? pt.bufa_ : pt.bufb_;
|
|
|
size_t readi = 0;
|
|
|
@@ -384,6 +392,19 @@ pair<bool, int> VectorPatternSource::nextBatch( |
|
|
return make_pair(cur_ == bufs_.size(), readi);
|
|
|
}
|
|
|
|
|
|
+pair<bool, int> VectorPatternSource::nextBatch(
|
|
|
+ PerThreadReadBuf& pt,
|
|
|
+ bool batch_a,
|
|
|
+ bool lock)
|
|
|
+{
|
|
|
+ if(lock) {
|
|
|
+ ThreadSafe ts(&mutex);
|
|
|
+ return nextBatchImpl(pt, batch_a);
|
|
|
+ } else {
|
|
|
+ return nextBatchImpl(pt, batch_a);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Finishes parsing outside the critical section.
|
|
|
*/
|
|
|
|
0 comments on commit
bccffc0