1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-18 00:54:19 +00:00

New class: ScopedPointer, which auto-releases a pointer when it goes out of scope. I've used this extensively to replace a lot of pointer deletions with more RAII-style patterns.

This commit is contained in:
Julian Storer 2010-01-02 23:01:18 +00:00
parent 4ed1d791e5
commit c22c06c80c
126 changed files with 1454 additions and 1838 deletions

View file

@ -28,12 +28,12 @@
BEGIN_JUCE_NAMESPACE
#include "juce_InterprocessConnectionServer.h"
#include "../containers/juce_ScopedPointer.h"
//==============================================================================
InterprocessConnectionServer::InterprocessConnectionServer()
: Thread ("Juce IPC server"),
socket (0)
: Thread ("Juce IPC server")
{
}
@ -55,7 +55,7 @@ bool InterprocessConnectionServer::beginWaitingForSocket (const int portNumber)
return true;
}
deleteAndZero (socket);
socket = 0;
return false;
}
@ -67,28 +67,21 @@ void InterprocessConnectionServer::stop()
socket->close();
stopThread (4000);
deleteAndZero (socket);
socket = 0;
}
void InterprocessConnectionServer::run()
{
while ((! threadShouldExit()) && socket != 0)
{
StreamingSocket* const clientSocket = socket->waitForNextConnection();
ScopedPointer <StreamingSocket> clientSocket (socket->waitForNextConnection());
if (clientSocket != 0)
{
InterprocessConnection* newConnection = createConnectionObject();
if (newConnection != 0)
{
newConnection->initialiseWithSocket (clientSocket);
}
else
{
delete clientSocket;
}
newConnection->initialiseWithSocket (clientSocket.release());
}
}
}