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

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

Bug fixes + more assertions to prevent similar errors.

File size: 20.4 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<CircularBuffer>(idb, idb->getStreamSetTy(encodingBits, 1), segmentSize * bufferSegments);
105    kernel::Kernel * s2pk = mGrepDriver->addKernelInstance<kernel::S2PKernel>(idb);
106    mGrepDriver->makeKernelCall(s2pk, {ByteStream}, {BasisBits});
107   
108    StreamSetBuffer * LineBreakStream = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
109    kernel::Kernel * linebreakK = mGrepDriver->addKernelInstance<kernel::LineBreakKernelBuilder>(idb, encodingBits);
110    mGrepDriver->makeKernelCall(linebreakK, {BasisBits}, {LineBreakStream});
111   
112    kernel::Kernel * requiredStreamsK = mGrepDriver->addKernelInstance<kernel::RequiredStreams_UTF8>(idb);
113    StreamSetBuffer * RequiredStreams = mGrepDriver->addBuffer<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<re::CC *>> charclasses(n);
119   
120    for (unsigned i = 0; i < n; i++) {
121        REs[i] = re::resolveNames(REs[i]);
122        const auto UnicodeSets = re::collectUnicodeSets(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<CircularBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses), segmentSize * bufferSegments);
133        kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::CharClassesKernel>(idb, std::move(charclasses[i]));
134        mGrepDriver->makeKernelCall(ccK, {BasisBits}, {CharClasses});
135        StreamSetBuffer * MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
136        kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<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<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
143        kernel::Kernel * streamsMergeK = mGrepDriver->addKernelInstance<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<kernel::MatchedLinesKernel>(idb);
151        Matches = mGrepDriver->addBuffer<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<kernel::InvertMatchesKernel>(idb);
157        StreamSetBuffer * OriginalMatches = Matches;
158        Matches = mGrepDriver->addBuffer<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<kernel::UntilNkernel>(idb);
163        untilK->setInitialArguments({idb->getSize(MaxCountFlag)});
164        StreamSetBuffer * AllMatches = Matches;
165        Matches = mGrepDriver->addBuffer<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 auto segmentSize = codegen::SegmentSize;
183    const auto bufferSegments = codegen::BufferSegments * codegen::ThreadNum;
184
185    const unsigned encodingBits = 8;
186   
187    Function * mainFunc = cast<Function>(M->getOrInsertFunction("Main", idb->getInt64Ty(), idb->getInt32Ty(), nullptr));
188    mainFunc->setCallingConv(CallingConv::C);
189    idb->SetInsertPoint(BasicBlock::Create(M->getContext(), "entry", mainFunc, 0));
190    auto args = mainFunc->arg_begin();
191   
192    Value * const fileDescriptor = &*(args++);
193    fileDescriptor->setName("fileDescriptor");
194   
195    StreamSetBuffer * ByteStream = mGrepDriver->addBuffer<SourceBuffer>(idb, idb->getStreamSetTy(1, encodingBits));
196    kernel::Kernel * sourceK = mGrepDriver->addKernelInstance<kernel::FDSourceKernel>(idb, segmentSize * bufferSegments);
197    sourceK->setInitialArguments({fileDescriptor});
198    mGrepDriver->makeKernelCall(sourceK, {}, {ByteStream});
199   
200    StreamSetBuffer * LineBreakStream;
201    StreamSetBuffer * Matches;
202    std::tie(LineBreakStream, Matches) = grepPipeline(REs, ByteStream);
203   
204    kernel::Kernel * matchCountK = mGrepDriver->addKernelInstance<kernel::PopcountKernel>(idb);
205    mGrepDriver->makeKernelCall(matchCountK, {Matches}, {});
206    mGrepDriver->generatePipelineIR();
207    idb->setKernel(matchCountK);
208    Value * matchedLineCount = idb->getAccumulator("countResult");
209    matchedLineCount = idb->CreateZExt(matchedLineCount, idb->getInt64Ty());
210    mGrepDriver->deallocateBuffers();
211    idb->CreateRet(matchedLineCount);
212    mGrepDriver->finalizeObject();
213}
214
215//
216// The EmitMatches engine uses an EmitMatchesAccumulator object to concatenate together
217// matched lines.
218
219class EmitMatch : public MatchAccumulator {
220    friend class EmitMatchesEngine;
221public:
222    EmitMatch(std::string linePrefix, std::stringstream * strm) : mLinePrefix(linePrefix), mLineCount(0), mPrevious_line_end(nullptr), mResultStr(strm) {}
223    void accumulate_match(const size_t lineNum, char * line_start, char * line_end) override;
224    void finalize_match(char * buffer_end) override;
225protected:
226    std::string mLinePrefix;
227    size_t mLineCount;
228    char * mPrevious_line_end;
229    std::stringstream* mResultStr;
230};
231
232//
233//  Default Report Match:  lines are emitted with whatever line terminators are found in the
234//  input.  However, if the final line is not terminated, a new line is appended.
235//
236//  It is possible that the line_end position is past the EOF, if there is an unterminated
237//  final line.   To avoid potential bus errors, we only emit bytes up to but not
238//  including the line_end position when we first find a match.
239void EmitMatch::accumulate_match (const size_t lineNum, char * line_start, char * line_end) {
240    if (!(WithFilenameFlag | LineNumberFlag) && (line_start == mPrevious_line_end + 1)) {
241        // Consecutive matches: only one write call needed.
242        mResultStr->write(mPrevious_line_end, line_end - mPrevious_line_end);
243    }
244    else {
245        if (mLineCount > 0) {
246            // Deal with the terminator of the previous line.  It could be an LF, the
247            // last byte of NEL, LS or PS, or a two byte CRLF sequence.
248            if (LLVM_UNLIKELY(mPrevious_line_end[0] == 0x0D)) {
249                mResultStr->write(mPrevious_line_end, mPrevious_line_end[1] == 0x0A ? 2 : 1);
250            }
251            else {
252                mResultStr->write(mPrevious_line_end, 1);
253            }
254        }
255        if (WithFilenameFlag) {
256            *mResultStr << mLinePrefix;
257        }
258        if (LineNumberFlag) {
259            // Internally line numbers are counted from 0.  For display, adjust
260            // the line number so that lines are numbered from 1.
261            if (InitialTabFlag) {
262                *mResultStr << lineNum+1 << "\t:";
263            }
264            else {
265                *mResultStr << lineNum+1 << ":";
266            }
267        }
268        mResultStr->write(line_start, line_end - line_start);
269    }
270    mPrevious_line_end = line_end;
271    mLineCount++;
272}
273
274void EmitMatch::finalize_match(char * buffer_end) {
275    if (mLineCount == 0) return;  // No matches.
276    if (mPrevious_line_end < buffer_end) {
277        if (LLVM_UNLIKELY(mPrevious_line_end[0] == 0x0D)) {
278            mResultStr->write(mPrevious_line_end, mPrevious_line_end[1] == 0x0A ? 2 : 1);
279        }
280        else {
281            mResultStr->write(mPrevious_line_end, 1);
282        }
283    }
284    else {
285        // Likely unterminated final line.
286        char last_byte = mPrevious_line_end[-1];
287        if (last_byte == 0x0D) {
288            // The final CR is acceptable as a line_end.
289            return;
290        }
291        // Terminate the line with an LF
292        // (Even if we had an incomplete UTF-8 sequence.)
293        *mResultStr << "\n";
294    }
295}
296
297void EmitMatchesEngine::grepCodeGen(std::vector<re::RE *> REs) {
298    assert (mGrepDriver == nullptr);
299    mGrepDriver = new ParabixDriver("engine");
300    auto & idb = mGrepDriver->getBuilder();
301    Module * M = idb->getModule();
302   
303    const auto segmentSize = codegen::SegmentSize;
304    const auto bufferSegments = codegen::BufferSegments * codegen::ThreadNum;
305    const unsigned encodingBits = 8;
306   
307    Function * mainFunc = cast<Function>(M->getOrInsertFunction("Main", idb->getInt64Ty(), idb->getInt32Ty(), idb->getIntAddrTy(), nullptr));
308    mainFunc->setCallingConv(CallingConv::C);
309    idb->SetInsertPoint(BasicBlock::Create(M->getContext(), "entry", mainFunc, 0));
310    auto args = mainFunc->arg_begin();
311   
312    Value * const fileDescriptor = &*(args++);
313    fileDescriptor->setName("fileDescriptor");
314    Value * match_accumulator = &*(args++);
315    match_accumulator->setName("match_accumulator");
316   
317    StreamSetBuffer * ByteStream = mGrepDriver->addBuffer<SourceBuffer>(idb, idb->getStreamSetTy(1, encodingBits));
318    kernel::Kernel * sourceK = mGrepDriver->addKernelInstance<kernel::FDSourceKernel>(idb, segmentSize * bufferSegments);
319    sourceK->setInitialArguments({fileDescriptor});
320    mGrepDriver->makeKernelCall(sourceK, {}, {ByteStream});
321   
322    StreamSetBuffer * LineBreakStream;
323    StreamSetBuffer * Matches;
324    std::tie(LineBreakStream, Matches) = grepPipeline(REs, ByteStream);
325   
326    kernel::Kernel * scanMatchK = mGrepDriver->addKernelInstance<kernel::ScanMatchKernel>(idb);
327    scanMatchK->setInitialArguments({match_accumulator});
328    mGrepDriver->makeKernelCall(scanMatchK, {Matches, LineBreakStream, ByteStream}, {});
329    mGrepDriver->LinkFunction(*scanMatchK, "accumulate_match_wrapper", &accumulate_match_wrapper);
330    mGrepDriver->LinkFunction(*scanMatchK, "finalize_match_wrapper", &finalize_match_wrapper);
331   
332    mGrepDriver->generatePipelineIR();
333    mGrepDriver->deallocateBuffers();
334    idb->CreateRet(idb->getInt64(0));
335    mGrepDriver->finalizeObject();
336}
337
338
339//
340//  The doGrep methods apply a GrepEngine to a single file, processing the results
341//  differently based on the engine type.
342   
343uint64_t GrepEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) {
344    typedef uint64_t (*GrepFunctionType)(int32_t fileDescriptor);
345    auto f = reinterpret_cast<GrepFunctionType>(mGrepDriver->getMain());
346   
347    int32_t fileDescriptor = openFile(fileName, mResultStrs[fileIdx].get());
348    if (fileDescriptor == -1) return 0;
349   
350    uint64_t grepResult = f(fileDescriptor);
351    close(fileDescriptor);
352    return grepResult;
353}
354
355uint64_t CountOnlyEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) {
356    uint64_t grepResult = GrepEngine::doGrep(fileName, fileIdx);
357    if (WithFilenameFlag) *mResultStrs[fileIdx] << linePrefix(fileName);
358    *mResultStrs[fileIdx] << grepResult << "\n";
359    return grepResult;
360}
361
362std::string GrepEngine::linePrefix(std::string fileName) {
363    if (fileName == "-") {
364        return LabelFlag + mFileSuffix;
365    }
366    else {
367        return fileName + mFileSuffix;
368    }
369}
370   
371uint64_t MatchOnlyEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) {
372    uint64_t grepResult = GrepEngine::doGrep(fileName, fileIdx);
373    if (grepResult == mRequiredCount) {
374       *mResultStrs[fileIdx] << linePrefix(fileName);
375    }
376    return grepResult;
377}
378
379uint64_t EmitMatchesEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) {
380    typedef uint64_t (*GrepFunctionType)(int32_t fileDescriptor, intptr_t accum_addr);
381    auto f = reinterpret_cast<GrepFunctionType>(mGrepDriver->getMain());
382   
383    int32_t fileDescriptor = openFile(fileName, mResultStrs[fileIdx].get());
384    if (fileDescriptor == -1) return 0;
385    EmitMatch accum(linePrefix(fileName), mResultStrs[fileIdx].get());
386    f(fileDescriptor, reinterpret_cast<intptr_t>(&accum));
387    close(fileDescriptor);
388    if (accum.mLineCount > 0) grepMatchFound = true;
389    return accum.mLineCount;
390}
391
392// Open a file and return its file desciptor.
393int32_t GrepEngine::openFile(const std::string & fileName, std::stringstream * msgstrm) {
394    if (fileName == "-") {
395        return STDIN_FILENO;
396    }
397    else {
398        struct stat sb;
399        int32_t fileDescriptor = open(fileName.c_str(), O_RDONLY);
400        if (LLVM_UNLIKELY(fileDescriptor == -1)) {
401            if (!NoMessagesFlag) {
402                if (errno == EACCES) {
403                    *msgstrm << "icgrep: " << fileName << ": Permission denied.\n";
404                }
405                else if (errno == ENOENT) {
406                    *msgstrm << "icgrep: " << fileName << ": No such file.\n";
407                }
408                else {
409                    *msgstrm << "icgrep: " << fileName << ": Failed.\n";
410                }
411            }
412            return fileDescriptor;
413        }
414        if (stat(fileName.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)) {
415            if (!NoMessagesFlag) {
416                *msgstrm << "icgrep: " << fileName << ": Is a directory.\n";
417            }
418            close(fileDescriptor);
419            return -1;
420        }
421        return fileDescriptor;
422    }
423}
424
425// The process of searching a group of files may use a sequential or a task
426// parallel approach.
427   
428void * DoGrepThreadFunction(void *args) {
429    return reinterpret_cast<GrepEngine *>(args)->DoGrepThreadMethod();
430}
431
432bool GrepEngine::searchAllFiles() {
433    const unsigned numOfThreads = Threads; // <- convert the command line value into an integer to allow stack allocation
434    pthread_t threads[numOfThreads];
435   
436    for(unsigned long i = 1; i < numOfThreads; ++i) {
437        const int rc = pthread_create(&threads[i], nullptr, DoGrepThreadFunction, (void *)this);
438        if (rc) {
439            llvm::report_fatal_error("Failed to create thread: code " + std::to_string(rc));
440        }
441    }
442    // Main thread also does the work;
443   
444    DoGrepThreadMethod();
445    for(unsigned i = 1; i < numOfThreads; ++i) {
446        void * status = nullptr;
447        const int rc = pthread_join(threads[i], &status);
448        if (rc) {
449            llvm::report_fatal_error("Failed to join thread: code " + std::to_string(rc));
450        }
451    }
452    return grepMatchFound;
453}
454
455
456// DoGrep thread function.
457void * GrepEngine::DoGrepThreadMethod() {
458    size_t fileIdx;
459
460    count_mutex.lock();
461    fileIdx = mNextFileToGrep;
462    if (fileIdx < inputFiles.size()) {
463        mFileStatus[fileIdx] = FileStatus::InGrep;
464        mNextFileToGrep++;
465    }
466    count_mutex.unlock();
467
468    while (fileIdx < inputFiles.size()) {
469        size_t grepResult = doGrep(inputFiles[fileIdx], fileIdx);
470       
471        count_mutex.lock();
472        mFileStatus[fileIdx] = FileStatus::GrepComplete;
473        if (grepResult > 0) grepMatchFound = true;
474        fileIdx = mNextFileToGrep;
475        if (fileIdx < inputFiles.size()) {
476            mFileStatus[fileIdx] = FileStatus::InGrep;
477            mNextFileToGrep++;
478        }
479        count_mutex.unlock();
480        if (QuietMode && grepMatchFound) {
481            if (pthread_self() != mEngineThread) pthread_exit(nullptr);
482            return nullptr;
483        }
484    }
485    count_mutex.lock();
486    fileIdx = mNextFileToPrint;
487    bool readyToPrint = ((fileIdx == 0) || (mFileStatus[fileIdx - 1] == FileStatus::PrintComplete)) && (mFileStatus[fileIdx] == FileStatus::GrepComplete);
488    if (fileIdx < inputFiles.size() && readyToPrint) {
489        mFileStatus[fileIdx] = FileStatus::Printing;
490        mNextFileToPrint++;
491    }
492    count_mutex.unlock();
493
494    while (fileIdx < inputFiles.size()) {
495        if (readyToPrint) {
496            std::cout << mResultStrs[fileIdx]->str();
497        } else if (pthread_self() == mEngineThread) {
498            mGrepDriver->performIncrementalCacheCleanupStep();
499        }
500        count_mutex.lock();
501        if (readyToPrint) mFileStatus[fileIdx] = FileStatus::PrintComplete;
502        fileIdx = mNextFileToPrint;
503        if (fileIdx < inputFiles.size()) {
504            readyToPrint = ((fileIdx == 0) || (mFileStatus[fileIdx - 1] == FileStatus::PrintComplete)) && (mFileStatus[fileIdx] == FileStatus::GrepComplete);
505            if (readyToPrint) {
506                mFileStatus[fileIdx] = FileStatus::Printing;
507                mNextFileToPrint++;
508            }
509        }
510        count_mutex.unlock();
511    }
512    if (pthread_self() != mEngineThread) {
513        pthread_exit(nullptr);
514    }
515    else {
516        return nullptr;
517    }
518}
519
520}
521
Note: See TracBrowser for help on using the repository browser.