Skip to content
Snippets Groups Projects
Commit 28e7eddd authored by Aaron Cuevas Lopez's avatar Aaron Cuevas Lopez
Browse files

Fix race condition on spike sorter

parent 8d9b08e4
No related branches found
No related tags found
No related merge requests found
......@@ -884,7 +884,7 @@ void SpikeSortBoxes::projectOnPrincipalComponents(SorterSpikePtr so)
bPCAJobSubmitted = true;
bRePCA = false;
// submit a new job to compute the spike buffer.
PCAjob job(spikeBuffer,pc1,pc2, &pc1min, &pc2min, &pc1max, &pc2max, &bPCAjobFinished);
PCAjob job(spikeBuffer,pc1,pc2, &pc1min, &pc2min, &pc1max, &pc2max, bPCAjobFinished);
computingThread->addPCAjob(job);
}
}
......@@ -1706,7 +1706,7 @@ static double sqrarg;
#define SQR(a) ((sqrarg = (a)) == 0.0 ? 0.0 : sqrarg * sqrarg)
PCAjob::PCAjob(SorterSpikeArray& _spikes, float* _pc1, float* _pc2,
float* pc1Min, float* pc2Min, float* pc1Max, float* pc2Max, bool* _reportDone) : spikes(_spikes), reportDone(_reportDone)
float* pc1Min, float* pc2Min, float* pc1Max, float* pc2Max, std::atomic<bool>& _reportDone) : spikes(_spikes), reportDone(_reportDone)
{
cov = nullptr;
pc1 = _pc1;
......@@ -2170,7 +2170,7 @@ void PCAcomputingThread::run()
J.computeSVD();
// 4. Report to the spike sorting electrode that PCA is finished
*(J.reportDone) = true;
J.reportDone = true;
}
}
......@@ -2239,4 +2239,4 @@ const SpikeChannel* SorterSpikeContainer::getChannel() const
int64 SorterSpikeContainer::getTimestamp() const
{
return timestamp;
}
\ No newline at end of file
}
......@@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <algorithm> // std::sort
#include <list>
#include <queue>
#include <atomic>
class SorterSpikeContainer : public ReferenceCountedObject
{
......@@ -180,7 +181,7 @@ class PCAjob
{
public:
PCAjob(SorterSpikeArray& _spikes, float* _pc1, float* _pc2,
float*, float*, float*, float*, bool* _reportDone);
float*, float*, float*, float*, std::atomic<bool>& _reportDone);
~PCAjob();
void computeCov();
void computeSVD();
......@@ -189,7 +190,7 @@ public:
SorterSpikeArray spikes;
float* pc1, *pc2;
float* pc1min, *pc2min, *pc1max, *pc2max;
bool* reportDone;
std::atomic<bool>& reportDone;
private:
int svdcmp(float** a, int nRows, int nCols, float* w, float** v);
float pythag(float a, float b);
......@@ -303,7 +304,8 @@ private:
SorterSpikeArray spikeBuffer;
int bufferSize,spikeBufferIndex;
PCAcomputingThread* computingThread;
bool bPCAJobSubmitted,bPCAcomputed,bRePCA,bPCAjobFinished ;
bool bPCAJobSubmitted,bPCAcomputed,bRePCA;
std::atomic<bool> bPCAjobFinished ;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment