Just want to make sure I'm using InterProcessLock Correctly

Hey, just looking for someone to let me know if I’m using InterProcessLock Correctly.

Basically, I have a ValueTree that needs to get saved to disk periodically.

Right now my save() function looks something like this

void Profile::save()
    //SaveLock is declared in the memeber variables as a InterProcessLock
    const InterProcessLock::ScopedLockType sl (saveLock);
    FileOutputStream os(saveFile);
    lastModTime = saveFile.getLastModificationTime();
    needsToSave = false;
    autoSaveCounter = 0;

Everything works fine, I’m just not too familiar with multithreading and locks so just want to double check this is correct. Sorry if this posts seems dumb lol

This lock is designed to work between different processes, not between threads. You want to use a CriticalSection for threads. Also, what is the data you want to protect from multithread access? Unless you are protecting file access, I would NOT lock for the file operation. Ideally you could lock, copy the data, unlock and do file operations with copy.