| 3876 | } |
| 3877 | |
| 3878 | void BfParser::Close() |
| 3879 | { |
| 3880 | BfSource::Close(); |
| 3881 | |
| 3882 | BfLogSys(mSystem, "Parser %p closing. RefCount:%d Failed:%d\n", this, mParserData->mRefCount, mParserData->mFailed); |
| 3883 | |
| 3884 | if ((mParserData->mRefCount == 0) && (!mParserData->mFailed)) |
| 3885 | { |
| 3886 | BF_ASSERT(mParserData->mDidReduce); |
| 3887 | |
| 3888 | AutoCrit autoCrit(gBfParserCache->mCritSect); |
| 3889 | BfParserCache::DataEntry dataEntry; |
| 3890 | dataEntry.mParserData = mParserData; |
| 3891 | if (gBfParserCache->mEntries.Add(dataEntry)) |
| 3892 | { |
| 3893 | BfLogSys(mSystem, "Parser %p added to cache\n", this); |
| 3894 | mParserData->mRefCount++; |
| 3895 | } |
| 3896 | else |
| 3897 | { |
| 3898 | // It's possible two of the same entries were being parsed at the same time on different threads. |
| 3899 | // Just let the loser be deleted in the dtor |
| 3900 | BfLogSys(mSystem, "Duplicate parser %p not added to cache\n", this); |
| 3901 | } |
| 3902 | } |
| 3903 | } |
| 3904 | |
| 3905 | void BfParser::HadSrcRealloc() |
| 3906 | { |
no test coverage detected