you don't need a semaphore for that, this code will work just as well (consider the type Image as the object that holds the image, this may differ from libraries):wth wrote:- Secured background loading thread with semaphore for cfws
Code: Select all
void loadNewBackgroundSafely(){
Image* aux = currentBackground; // backup current background
currentBackground = loadImage(path); // load the new image
delete aux; // delete the older one
}
Advertising