remove position pool

This commit is contained in:
Yaossg 2025-01-19 20:20:07 +08:00
parent cd6f37900d
commit ebac0d06a6

View File

@ -195,7 +195,6 @@ public:
long long int location; // current location (position) in reference chromosome. long long int location; // current location (position) in reference chromosome.
char lastBase = 'X'; // the last base of reference line. this is for CG_only mode. char lastBase = 'X'; // the last base of reference line. this is for CG_only mode.
Channel<string> linePool; // pool to store unprocessed SAM line. Channel<string> linePool; // pool to store unprocessed SAM line.
Channel<Position*> freePositionPool; // pool to store free position pointer for reference position.
Channel<Position*> outputPositionPool; // pool to store the reference position which is loaded and ready to output. Channel<Position*> outputPositionPool; // pool to store the reference position which is loaded and ready to output.
mutex mutex_; mutex mutex_;
long long int refCoveredPosition; // this is the last position in reference chromosome we loaded in refPositions. long long int refCoveredPosition; // this is the last position in reference chromosome we loaded in refPositions.
@ -222,10 +221,10 @@ public:
delete workerLock[i]; delete workerLock[i];
} }
Position* pos; Position* pos;
freePositionPool.close(); // freePositionPool.close();
while(freePositionPool.recv(pos)) { // while(freePositionPool.recv(pos)) {
delete pos; // delete pos;
} // }
} }
/** /**
@ -478,19 +477,14 @@ public:
* get a Position pointer from freePositionPool, if freePositionPool is empty, make a new Position pointer. * get a Position pointer from freePositionPool, if freePositionPool is empty, make a new Position pointer.
*/ */
void getFreePosition(Position*& newPosition) { void getFreePosition(Position*& newPosition) {
if (freePositionPool.recv(newPosition)) { newPosition = new Position();
return;
} else {
newPosition = new Position();
}
} }
/** /**
* return the position to freePositionPool. * return the position to freePositionPool.
*/ */
void returnPosition(Position* pos) { void returnPosition(Position* pos) {
pos->initialize(); delete pos;
freePositionPool.send(pos);
} }
/** /**