Last active
July 24, 2017 21:54
-
-
Save Craigson/cc217da3638daa2724bfec6efbc1d6f1 to your computer and use it in GitHub Desktop.
concurrent_buffer.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConcurrentCircularBuffer<Surface8u> *mFrameQueue; | |
std::thread mWorkerThread; | |
setup(){ | |
mFrameQueue = new ConcurrentCircularBuffer<Surface8u>(90); | |
mWorkerThread = std::thread([&] { | |
console() << "CREATING WORKER THREAD " << std::endl; | |
static int kNextFrame = 0; | |
static bool running = true; | |
while (running) | |
{ | |
while (mFrameQueue->isNotEmpty()) { | |
Surface8u frame; | |
mFrameQueue->popBack(&frame); | |
writeImage("Frame_" + std::to_string(kNextFrame++) + ".png", frame); | |
//mMovieWriters[mMovieWriters.size() - 1]->addFrame(frame, 1.f / 30.f); | |
}; | |
}; | |
}); | |
} | |
update() | |
{ | |
mFrameQueue->pushFront(*mCameraManager.getSurface()); // checks internally if a new frame is available | |
console() << "update: size of mFrameQueue: " << mFrameQueue->getSize() << std::endl; | |
} | |
/* | |
Errors: | |
Microsoft C++ exception: std::bad_alloc at memory location 0x0019F8BC. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment