1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

iOS InterprocessLock changes.

This commit is contained in:
jules 2011-11-10 14:32:35 +00:00
parent 5e90767eb2
commit 93d6f4183b
2 changed files with 13 additions and 2 deletions

View file

@ -176,7 +176,12 @@ bool NamedPipe::openInternal (const String& pipeName, const bool createPipe)
{
close();
#if JUCE_IOS
pimpl = new Pimpl (File::getSpecialLocation (File::tempDirectory)
.getChildFile (File::createLegalFileName (pipeName)).getFullPathName(), createPipe);
#else
pimpl = new Pimpl ("/tmp/" + File::createLegalFileName (pipeName), createPipe);
#endif
if (createPipe && ! pimpl->createFifos())
{

View file

@ -665,6 +665,9 @@ public:
Pimpl (const String& name, const int timeOutMillisecs)
: handle (0), refCount (1)
{
#if JUCE_IOS
handle = 1; // On iOS we can't run multiple apps, so just assume success.
#else
// Note that we can't get the normal temp folder here, as it might be different for each app.
File tempFolder ("/var/tmp");
@ -703,6 +706,7 @@ public:
}
closeFile();
#endif
}
~Pimpl()
@ -712,6 +716,7 @@ public:
void closeFile()
{
#if ! JUCE_IOS
if (handle != 0)
{
struct flock fl = { 0 };
@ -724,6 +729,7 @@ public:
close (handle);
handle = 0;
}
#endif
}
int handle, refCount;
@ -747,7 +753,7 @@ bool InterProcessLock::enter (const int timeOutMillisecs)
pimpl = new Pimpl (name, timeOutMillisecs);
if (pimpl->handle == 0)
pimpl = 0;
pimpl = nullptr;
}
else
{
@ -765,7 +771,7 @@ void InterProcessLock::exit()
jassert (pimpl != nullptr);
if (pimpl != nullptr && --(pimpl->refCount) == 0)
pimpl = 0;
pimpl = nullptr;
}
//==============================================================================