source: icGREP/icgrep-devel/icgrep/grep_engine.cpp @ 5740

Last change on this file since 5740 was 5740, checked in by nmedfort, 16 months ago

Bug fix for Grep Engine + better bug fix for UnicodeSet?

File size: 20.5 KB
Line 
1/*
2 *  Copyright (c) 2017 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#include "grep_engine.h"
8#include "grep_interface.h"
9#include <llvm/IR/Module.h>
10#include <boost/filesystem.hpp>
11#include <UCD/resolve_properties.h>
12#include <kernels/charclasses.h>
13#include <kernels/cc_kernel.h>
14#include <kernels/grep_kernel.h>
15#include <kernels/linebreak_kernel.h>
16#include <kernels/streams_merge.h>
17#include <kernels/source_kernel.h>
18#include <kernels/s2p_kernel.h>
19#include <kernels/scanmatchgen.h>
20#include <kernels/streamset.h>
21#include <kernels/until_n.h>
22#include <kernels/kernel_builder.h>
23#include <pablo/pablo_kernel.h>
24#include <re/re_cc.h>
25#include <re/re_toolchain.h>
26#include <toolchain/toolchain.h>
27#include <re/re_name_resolve.h>   
28#include <re/re_collect_unicodesets.h>
29#include <re/re_multiplex.h>
30#include <toolchain/toolchain.h>
31#include <toolchain/cpudriver.h>
32#include <iostream>
33#include <cc/multiplex_CCs.h>
34#include <llvm/Support/raw_ostream.h>
35#include <util/aligned_allocator.h>
36#include <sys/stat.h>
37#include <fcntl.h>
38#include <errno.h>
39#include <llvm/ADT/STLExtras.h> // for make_unique
40#include <llvm/Support/CommandLine.h>
41#include <llvm/Support/Debug.h>
42
43using namespace parabix;
44using namespace llvm;
45static cl::opt<int> Threads("t", cl::desc("Total number of threads."), cl::init(2));
46
47namespace grep {
48
49// Grep Engine construction and initialization.
50   
51GrepEngine::GrepEngine() :
52    mGrepDriver(nullptr),
53    mNextFileToGrep(0),
54    mNextFileToPrint(0),
55    grepMatchFound(false),
56    mMoveMatchesToEOL(true),
57    mEngineThread(pthread_self()) {}
58   
59GrepEngine::~GrepEngine() {
60    delete mGrepDriver;
61}
62   
63QuietModeEngine::QuietModeEngine() : GrepEngine() {
64    mMoveMatchesToEOL = false;
65}
66
67MatchOnlyEngine::MatchOnlyEngine(bool showFilesWithoutMatch) :
68    GrepEngine(), mRequiredCount(showFilesWithoutMatch) {
69    mFileSuffix = NullFlag ? std::string("\0", 1) : "\n";
70    mMoveMatchesToEOL = false;
71}
72
73CountOnlyEngine::CountOnlyEngine() : GrepEngine() {
74    mFileSuffix = ":";
75}
76
77EmitMatchesEngine::EmitMatchesEngine() : GrepEngine() {
78    mFileSuffix = InitialTabFlag ? "\t:" : ":";
79    if (LineRegexpFlag) mMoveMatchesToEOL = false;
80}
81
82void GrepEngine::initFileResult(std::vector<std::string> & filenames) {
83    const unsigned n = filenames.size();
84    mResultStrs.resize(n);
85    mFileStatus.resize(n);
86    for (unsigned i = 0; i < n; i++) {
87        mResultStrs[i] = make_unique<std::stringstream>();
88        mFileStatus[i] = FileStatus::Pending;
89    }
90    inputFiles = filenames;
91}
92   
93
94// Code Generation
95//
96// All engines share a common pipeline to compute a stream of Matches from a given input Bytestream.
97
98std::pair<StreamSetBuffer *, StreamSetBuffer *> GrepEngine::grepPipeline(std::vector<re::RE *> & REs, StreamSetBuffer * ByteStream) {
99    auto & idb = mGrepDriver->getBuilder();
100    const unsigned segmentSize = codegen::SegmentSize;
101    const unsigned bufferSegments = codegen::BufferSegments * codegen::ThreadNum;
102    const unsigned encodingBits = 8;
103   
104    StreamSetBuffer * BasisBits = mGrepDriver->addBuffer(make_unique<CircularBuffer>(idb, idb->getStreamSetTy(encodingBits, 1), segmentSize * bufferSegments));
105    kernel::Kernel * s2pk = mGrepDriver->addKernelInstance(make_unique<kernel::S2PKernel>(idb));
106    mGrepDriver->makeKernelCall(s2pk, {ByteStream}, {BasisBits});
107   
108    StreamSetBuffer * LineBreakStream = mGrepDriver->addBuffer(make_unique<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments));
109    kernel::Kernel * linebreakK = mGrepDriver->addKernelInstance(make_unique<kernel::LineBreakKernelBuilder>(idb, encodingBits));
110    mGrepDriver->makeKernelCall(linebreakK, {BasisBits}, {LineBreakStream});
111   
112    kernel::Kernel * requiredStreamsK = mGrepDriver->addKernelInstance(make_unique<kernel::RequiredStreams_UTF8>(idb));
113    StreamSetBuffer * RequiredStreams = mGrepDriver->addBuffer(make_unique<CircularBuffer>(idb, idb->getStreamSetTy(4, 1), segmentSize * bufferSegments));
114    mGrepDriver->makeKernelCall(requiredStreamsK, {BasisBits}, {RequiredStreams});
115   
116    const auto n = REs.size();
117   
118    std::vector<std::vector<UCD::UnicodeSet>> charclasses(n);
119   
120    for (unsigned i = 0; i < n; i++) {
121        REs[i] = re::resolveNames(REs[i]);
122        std::vector<UCD::UnicodeSet> UnicodeSets = re::collect_UnicodeSets(REs[i]);
123        std::vector<std::vector<unsigned>> exclusiveSetIDs;
124        doMultiplexCCs(UnicodeSets, exclusiveSetIDs, charclasses[i]);
125        REs[i] = multiplex(REs[i], UnicodeSets, exclusiveSetIDs);
126    }
127   
128    std::vector<StreamSetBuffer *> MatchResultsBufs(n);
129   
130    for(unsigned i = 0; i < n; ++i){
131        const auto numOfCharacterClasses = charclasses[i].size();
132        StreamSetBuffer * CharClasses = mGrepDriver->addBuffer(make_unique<CircularBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses), segmentSize * bufferSegments));
133        kernel::Kernel * ccK = mGrepDriver->addKernelInstance(make_unique<kernel::CharClassesKernel>(idb, std::move(charclasses[i])));
134        mGrepDriver->makeKernelCall(ccK, {BasisBits}, {CharClasses});
135        StreamSetBuffer * MatchResults = mGrepDriver->addBuffer(make_unique<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments));
136        kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance(make_unique<kernel::ICGrepKernel>(idb, REs[i], numOfCharacterClasses));
137        mGrepDriver->makeKernelCall(icgrepK, {CharClasses, LineBreakStream, RequiredStreams}, {MatchResults});
138        MatchResultsBufs[i] = MatchResults;
139    }
140    StreamSetBuffer * MergedResults = MatchResultsBufs[0];
141    if (REs.size() > 1) {
142        MergedResults = mGrepDriver->addBuffer(make_unique<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments));
143        kernel::Kernel * streamsMergeK = mGrepDriver->addKernelInstance(make_unique<kernel::StreamsMerge>(idb, 1, REs.size()));
144        mGrepDriver->makeKernelCall(streamsMergeK, MatchResultsBufs, {MergedResults});
145    }
146    StreamSetBuffer * Matches = MergedResults;
147   
148    if (mMoveMatchesToEOL) {
149        StreamSetBuffer * OriginalMatches = Matches;
150        kernel::Kernel * matchedLinesK = mGrepDriver->addKernelInstance(make_unique<kernel::MatchedLinesKernel>(idb));
151        Matches = mGrepDriver->addBuffer(make_unique<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments));
152        mGrepDriver->makeKernelCall(matchedLinesK, {OriginalMatches, LineBreakStream}, {Matches});
153    }
154   
155    if (InvertMatchFlag) {
156        kernel::Kernel * invertK = mGrepDriver->addKernelInstance(make_unique<kernel::InvertMatchesKernel>(idb));
157        StreamSetBuffer * OriginalMatches = Matches;
158        Matches = mGrepDriver->addBuffer(make_unique<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments));
159        mGrepDriver->makeKernelCall(invertK, {OriginalMatches, LineBreakStream}, {Matches});
160    }
161    if (MaxCountFlag > 0) {
162        kernel::Kernel * untilK = mGrepDriver->addKernelInstance(make_unique<kernel::UntilNkernel>(idb));
163        untilK->setInitialArguments({idb->getSize(MaxCountFlag)});
164        StreamSetBuffer * AllMatches = Matches;
165        Matches = mGrepDriver->addBuffer(make_unique<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments));
166        mGrepDriver->makeKernelCall(untilK, {AllMatches}, {Matches});
167    }
168    return std::pair<StreamSetBuffer *, StreamSetBuffer *>(LineBreakStream, Matches);
169}
170
171// The QuietMode, MatchOnly and CountOnly engines share a common code generation main function,
172// which returns a count of the matches found (possibly subject to a MaxCount).
173//
174
175void GrepEngine::grepCodeGen(std::vector<re::RE *> REs) {
176   
177    assert (mGrepDriver == nullptr);
178    mGrepDriver = new ParabixDriver("engine");
179    auto & idb = mGrepDriver->getBuilder();
180    Module * M = idb->getModule();
181   
182    const unsigned segmentSize = codegen::SegmentSize;
183    const unsigned encodingBits = 8;
184   
185    Function * mainFunc = cast<Function>(M->getOrInsertFunction("Main", idb->getInt64Ty(), idb->getInt32Ty(), nullptr));
186    mainFunc->setCallingConv(CallingConv::C);
187    idb->SetInsertPoint(BasicBlock::Create(M->getContext(), "entry", mainFunc, 0));
188    auto args = mainFunc->arg_begin();
189   
190    Value * const fileDescriptor = &*(args++);
191    fileDescriptor->setName("fileDescriptor");
192   
193    StreamSetBuffer * ByteStream = mGrepDriver->addBuffer(make_unique<SourceBuffer>(idb, idb->getStreamSetTy(1, encodingBits)));
194    kernel::Kernel * sourceK = mGrepDriver->addKernelInstance(make_unique<kernel::FDSourceKernel>(idb, segmentSize));
195    sourceK->setInitialArguments({fileDescriptor});
196    mGrepDriver->makeKernelCall(sourceK, {}, {ByteStream});
197   
198    StreamSetBuffer * LineBreakStream;
199    StreamSetBuffer * Matches;
200    std::tie(LineBreakStream, Matches) = grepPipeline(REs, ByteStream);
201   
202    kernel::Kernel * matchCountK = mGrepDriver->addKernelInstance(make_unique<kernel::PopcountKernel>(idb));
203    mGrepDriver->makeKernelCall(matchCountK, {Matches}, {});
204    mGrepDriver->generatePipelineIR();
205    idb->setKernel(matchCountK);
206    Value * matchedLineCount = idb->getAccumulator("countResult");
207    matchedLineCount = idb->CreateZExt(matchedLineCount, idb->getInt64Ty());
208    mGrepDriver->deallocateBuffers();
209    idb->CreateRet(matchedLineCount);
210    mGrepDriver->finalizeObject();
211}
212
213//
214// The EmitMatches engine uses an EmitMatchesAccumulator object to concatenate together
215// matched lines.
216
217class EmitMatch : public MatchAccumulator {
218    friend class EmitMatchesEngine;
219public:
220    EmitMatch(std::string linePrefix, std::stringstream * strm) : mLinePrefix(linePrefix), mLineCount(0), mPrevious_line_end(nullptr), mResultStr(strm) {}
221    void accumulate_match(const size_t lineNum, char * line_start, char * line_end) override;
222    void finalize_match(char * buffer_end) override;
223protected:
224    std::string mLinePrefix;
225    size_t mLineCount;
226    char * mPrevious_line_end;
227    std::stringstream* mResultStr;
228};
229
230//
231//  Default Report Match:  lines are emitted with whatever line terminators are found in the
232//  input.  However, if the final line is not terminated, a new line is appended.
233//
234//  It is possible that the line_end position is past the EOF, if there is an unterminated
235//  final line.   To avoid potential bus errors, we only emit bytes up to but not
236//  including the line_end position when we first find a match.
237void EmitMatch::accumulate_match (const size_t lineNum, char * line_start, char * line_end) {
238    if (!(WithFilenameFlag | LineNumberFlag) && (line_start == mPrevious_line_end + 1)) {
239        // Consecutive matches: only one write call needed.
240        mResultStr->write(mPrevious_line_end, line_end - mPrevious_line_end);
241    }
242    else {
243        if (mLineCount > 0) {
244            // Deal with the terminator of the previous line.  It could be an LF, the
245            // last byte of NEL, LS or PS, or a two byte CRLF sequence.
246            if (LLVM_UNLIKELY(mPrevious_line_end[0] == 0x0D)) {
247                mResultStr->write(mPrevious_line_end, mPrevious_line_end[1] == 0x0A ? 2 : 1);
248            }
249            else {
250                mResultStr->write(mPrevious_line_end, 1);
251            }
252        }
253        if (WithFilenameFlag) {
254            *mResultStr << mLinePrefix;
255        }
256        if (LineNumberFlag) {
257            // Internally line numbers are counted from 0.  For display, adjust
258            // the line number so that lines are numbered from 1.
259            if (InitialTabFlag) {
260                *mResultStr << lineNum+1 << "\t:";
261            }
262            else {
263                *mResultStr << lineNum+1 << ":";
264            }
265        }
266        mResultStr->write(line_start, line_end - line_start);
267    }
268    mPrevious_line_end = line_end;
269    mLineCount++;
270}
271
272void EmitMatch::finalize_match(char * buffer_end) {
273    if (mLineCount == 0) return;  // No matches.
274    if (mPrevious_line_end < buffer_end) {
275        if (LLVM_UNLIKELY(mPrevious_line_end[0] == 0x0D)) {
276            mResultStr->write(mPrevious_line_end, mPrevious_line_end[1] == 0x0A ? 2 : 1);
277        }
278        else {
279            mResultStr->write(mPrevious_line_end, 1);
280        }
281    }
282    else {
283        // Likely unterminated final line.
284        char last_byte = mPrevious_line_end[-1];
285        if (last_byte == 0x0D) {
286            // The final CR is acceptable as a line_end.
287            return;
288        }
289        // Terminate the line with an LF
290        // (Even if we had an incomplete UTF-8 sequence.)
291        *mResultStr << "\n";
292    }
293}
294
295void EmitMatchesEngine::grepCodeGen(std::vector<re::RE *> REs) {
296    assert (mGrepDriver == nullptr);
297    mGrepDriver = new ParabixDriver("engine");
298    auto & idb = mGrepDriver->getBuilder();
299    Module * M = idb->getModule();
300   
301    const unsigned segmentSize = codegen::SegmentSize;
302    const unsigned encodingBits = 8;
303   
304    Function * mainFunc = cast<Function>(M->getOrInsertFunction("Main", idb->getInt64Ty(), idb->getInt32Ty(), idb->getIntAddrTy(), nullptr));
305    mainFunc->setCallingConv(CallingConv::C);
306    idb->SetInsertPoint(BasicBlock::Create(M->getContext(), "entry", mainFunc, 0));
307    auto args = mainFunc->arg_begin();
308   
309    Value * const fileDescriptor = &*(args++);
310    fileDescriptor->setName("fileDescriptor");
311    Value * match_accumulator = &*(args++);
312    match_accumulator->setName("match_accumulator");
313   
314    StreamSetBuffer * ByteStream = mGrepDriver->addBuffer(make_unique<SourceBuffer>(idb, idb->getStreamSetTy(1, encodingBits)));
315    kernel::Kernel * sourceK = mGrepDriver->addKernelInstance(make_unique<kernel::FDSourceKernel>(idb, segmentSize));
316    sourceK->setInitialArguments({fileDescriptor});
317    mGrepDriver->makeKernelCall(sourceK, {}, {ByteStream});
318   
319    StreamSetBuffer * LineBreakStream;
320    StreamSetBuffer * Matches;
321    std::tie(LineBreakStream, Matches) = grepPipeline(REs, ByteStream);
322   
323    kernel::Kernel * scanMatchK = mGrepDriver->addKernelInstance(make_unique<kernel::ScanMatchKernel>(idb));
324    scanMatchK->setInitialArguments({match_accumulator});
325    mGrepDriver->makeKernelCall(scanMatchK, {Matches, LineBreakStream, ByteStream}, {});
326    mGrepDriver->LinkFunction(*scanMatchK, "accumulate_match_wrapper", &accumulate_match_wrapper);
327    mGrepDriver->LinkFunction(*scanMatchK, "finalize_match_wrapper", &finalize_match_wrapper);
328   
329    mGrepDriver->generatePipelineIR();
330    mGrepDriver->deallocateBuffers();
331    idb->CreateRet(idb->getInt64(0));
332    mGrepDriver->finalizeObject();
333}
334
335
336//
337//  The doGrep methods apply a GrepEngine to a single file, processing the results
338//  differently based on the engine type.
339   
340uint64_t GrepEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) {
341    typedef uint64_t (*GrepFunctionType)(int32_t fileDescriptor);
342    auto f = reinterpret_cast<GrepFunctionType>(mGrepDriver->getMain());
343   
344    int32_t fileDescriptor = openFile(fileName, mResultStrs[fileIdx].get());
345    if (fileDescriptor == -1) return 0;
346   
347    uint64_t grepResult = f(fileDescriptor);
348    close(fileDescriptor);
349    return grepResult;
350}
351
352uint64_t CountOnlyEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) {
353    uint64_t grepResult = GrepEngine::doGrep(fileName, fileIdx);
354    if (WithFilenameFlag) *mResultStrs[fileIdx] << linePrefix(fileName);
355    *mResultStrs[fileIdx] << grepResult << "\n";
356    return grepResult;
357}
358
359std::string GrepEngine::linePrefix(std::string fileName) {
360    if (fileName == "-") {
361        return LabelFlag + mFileSuffix;
362    }
363    else {
364        return fileName + mFileSuffix;
365    }
366}
367   
368uint64_t MatchOnlyEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) {
369    uint64_t grepResult = GrepEngine::doGrep(fileName, fileIdx);
370    if (grepResult == mRequiredCount) {
371       *mResultStrs[fileIdx] << linePrefix(fileName);
372    }
373    return grepResult;
374}
375
376uint64_t EmitMatchesEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) {
377    typedef uint64_t (*GrepFunctionType)(int32_t fileDescriptor, intptr_t accum_addr);
378    auto f = reinterpret_cast<GrepFunctionType>(mGrepDriver->getMain());
379   
380    int32_t fileDescriptor = openFile(fileName, mResultStrs[fileIdx].get());
381    if (fileDescriptor == -1) return 0;
382    EmitMatch accum(linePrefix(fileName), mResultStrs[fileIdx].get());
383    f(fileDescriptor, reinterpret_cast<intptr_t>(&accum));
384    close(fileDescriptor);
385    if (accum.mLineCount > 0) grepMatchFound = true;
386    return accum.mLineCount;
387}
388
389// Open a file and return its file desciptor.
390int32_t GrepEngine::openFile(const std::string & fileName, std::stringstream * msgstrm) {
391    if (fileName == "-") {
392        return STDIN_FILENO;
393    }
394    else {
395        struct stat sb;
396        int32_t fileDescriptor = open(fileName.c_str(), O_RDONLY);
397        if (LLVM_UNLIKELY(fileDescriptor == -1)) {
398            if (!NoMessagesFlag) {
399                if (errno == EACCES) {
400                    *msgstrm << "icgrep: " << fileName << ": Permission denied.\n";
401                }
402                else if (errno == ENOENT) {
403                    *msgstrm << "icgrep: " << fileName << ": No such file.\n";
404                }
405                else {
406                    *msgstrm << "icgrep: " << fileName << ": Failed.\n";
407                }
408            }
409            return fileDescriptor;
410        }
411        if (stat(fileName.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)) {
412            if (!NoMessagesFlag) {
413                *msgstrm << "icgrep: " << fileName << ": Is a directory.\n";
414            }
415            close(fileDescriptor);
416            return -1;
417        }
418        return fileDescriptor;
419    }
420}
421
422// The process of searching a group of files may use a sequential or a task
423// parallel approach.
424   
425void * DoGrepThreadFunction(void *args) {
426    return reinterpret_cast<GrepEngine *>(args)->DoGrepThreadMethod();
427}
428
429bool GrepEngine::searchAllFiles() {
430    const unsigned numOfThreads = Threads; // <- convert the command line value into an integer to allow stack allocation
431    pthread_t threads[numOfThreads];
432   
433    for(unsigned long i = 1; i < numOfThreads; ++i) {
434        const int rc = pthread_create(&threads[i], nullptr, DoGrepThreadFunction, (void *)this);
435        if (rc) {
436            llvm::report_fatal_error("Failed to create thread: code " + std::to_string(rc));
437        }
438    }
439    // Main thread also does the work;
440   
441    DoGrepThreadMethod();
442    for(unsigned i = 1; i < numOfThreads; ++i) {
443        void * status = nullptr;
444        const int rc = pthread_join(threads[i], &status);
445        if (rc) {
446            llvm::report_fatal_error("Failed to join thread: code " + std::to_string(rc));
447        }
448    }
449    return grepMatchFound;
450}
451
452
453// DoGrep thread function.
454void * GrepEngine::DoGrepThreadMethod() {
455    size_t fileIdx;
456
457    count_mutex.lock();
458    fileIdx = mNextFileToGrep;
459    if (fileIdx < inputFiles.size()) {
460        mFileStatus[fileIdx] = FileStatus::InGrep;
461        mNextFileToGrep++;
462    }
463    count_mutex.unlock();
464
465    while (fileIdx < inputFiles.size()) {
466        size_t grepResult = doGrep(inputFiles[fileIdx], fileIdx);
467       
468        count_mutex.lock();
469        mFileStatus[fileIdx] = FileStatus::GrepComplete;
470        if (grepResult > 0) grepMatchFound = true;
471        fileIdx = mNextFileToGrep;
472        if (fileIdx < inputFiles.size()) {
473            mFileStatus[fileIdx] = FileStatus::InGrep;
474            mNextFileToGrep++;
475        }
476        count_mutex.unlock();
477        if (QuietMode && grepMatchFound) {
478            if (pthread_self() != mEngineThread) pthread_exit(nullptr);
479            return nullptr;
480        }
481    }
482    count_mutex.lock();
483    fileIdx = mNextFileToPrint;
484    bool readyToPrint = ((fileIdx == 0) || (mFileStatus[fileIdx - 1] == FileStatus::PrintComplete)) && (mFileStatus[fileIdx] == FileStatus::GrepComplete);
485    if (fileIdx < inputFiles.size() && readyToPrint) {
486        mFileStatus[fileIdx] = FileStatus::Printing;
487        mNextFileToPrint++;
488    }
489    count_mutex.unlock();
490
491    while (fileIdx < inputFiles.size()) {
492        if (readyToPrint) {
493            std::cout << mResultStrs[fileIdx]->str();
494        } else if (pthread_self() == mEngineThread) {
495            mGrepDriver->performIncrementalCacheCleanupStep();
496        }
497        count_mutex.lock();
498        if (readyToPrint) mFileStatus[fileIdx] = FileStatus::PrintComplete;
499        fileIdx = mNextFileToPrint;
500        if (fileIdx < inputFiles.size()) {
501            readyToPrint = ((fileIdx == 0) || (mFileStatus[fileIdx - 1] == FileStatus::PrintComplete)) && (mFileStatus[fileIdx] == FileStatus::GrepComplete);
502            if (readyToPrint) {
503                mFileStatus[fileIdx] = FileStatus::Printing;
504                mNextFileToPrint++;
505            }
506        }
507        count_mutex.unlock();
508    }
509    if (pthread_self() != mEngineThread) {
510        pthread_exit(nullptr);
511    }
512    else {
513        return nullptr;
514    }
515}
516
517}
518
Note: See TracBrowser for help on using the repository browser.