41 return openInternal (
pipeName,
false,
false);
47 return pimpl !=
nullptr;
62 return currentPipeName;
80 void runTest()
override
84 beginTest (
"Pre test cleanup");
90 beginTest (
"Create pipe");
93 expect (!
pipe.isOpen());
96 expect (
pipe.isOpen());
99 expect (
pipe.isOpen());
106 beginTest (
"Existing pipe");
111 expect (!
pipe.isOpen());
122 beginTest (
"Receive message created pipe");
137 expectEquals (bytesRead, (
int)
sizeof (
recvData));
142 beginTest (
"Receive message existing pipe");
157 expectEquals (bytesRead, (
int)
sizeof (
recvData));
162 beginTest (
"Send message created pipe");
170 receiver.startThread();
176 expectEquals (bytesWritten, (
int)
sizeof (
sendData));
177 expectEquals (receiver.result, (
int)
sizeof (receiver.recvData));
178 expectEquals (receiver.recvData,
sendData);
181 beginTest (
"Send message existing pipe");
189 receiver.startThread();
195 expectEquals (bytesWritten, (
int)
sizeof (
sendData));
196 expectEquals (receiver.result, (
int)
sizeof (receiver.recvData));
197 expectEquals (receiver.recvData,
sendData);
205 NamedPipeThread (
const String& tName,
const String& pName,
206 bool shouldCreatePipe, WaitableEvent& completed)
207 : Thread (tName), pipeName (pName), workCompleted (completed)
209 if (shouldCreatePipe)
210 pipe.createNewPipe (pipeName);
212 pipe.openExisting (pipeName);
216 const String& pipeName;
217 WaitableEvent& workCompleted;
225 SenderThread (
const String& pName,
bool shouldCreatePipe,
226 WaitableEvent& completed,
int sData)
227 : NamedPipeThread (
"NamePipeSender", pName, shouldCreatePipe, completed),
231 ~SenderThread()
override
238 result =
pipe.write (&sendData,
sizeof (sendData), 2000);
239 workCompleted.signal();
248 ReceiverThread (
const String& pName,
bool shouldCreatePipe,
249 WaitableEvent& completed)
250 : NamedPipeThread (
"NamePipeSender", pName, shouldCreatePipe, completed)
253 ~ReceiverThread()
override
260 result =
pipe.read (&recvData,
sizeof (recvData), 2000);
261 workCompleted.signal();
String getName() const
Returns the last name that was used to try to open this pipe.
bool isOpen() const
True if the pipe is currently open.
bool createNewPipe(const String &pipeName, bool mustNotExist=false)
Tries to create a new pipe.
NamedPipe()
Creates a NamedPipe.
bool openExisting(const String &pipeName)
Tries to open a pipe that already exists.
void close()
Closes the pipe, if it's open.
Automatically locks and unlocks a ReadWriteLock object.
Automatically locks and unlocks a ReadWriteLock object.
static ThreadID JUCE_CALLTYPE getCurrentThreadId()
Returns an id that identifies the caller thread.
This is a base class for classes that perform a unit test.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...