2 ==============================================================================
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
7 JUCE is an open source library subject to commercial or open-source
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
20 ==============================================================================
26 //==============================================================================
28 A cross-process pipe that can have data written to and read from it.
30 Two processes can use NamedPipe objects to exchange blocks of data.
32 @see InterprocessConnection
36 class JUCE_API NamedPipe final
39 //==============================================================================
40 /** Creates a NamedPipe. */
46 //==============================================================================
47 /** Tries to open a pipe that already exists.
48 Returns true if it succeeds.
50 bool openExisting (const String
& pipeName
);
52 /** Tries to create a new pipe.
53 Returns true if it succeeds.
54 If mustNotExist is true then it will fail if a pipe is already
55 open with the same name.
57 bool createNewPipe (const String
& pipeName
, bool mustNotExist
= false);
59 /** Closes the pipe, if it's open. */
62 /** True if the pipe is currently open. */
65 /** Returns the last name that was used to try to open this pipe. */
66 String
getName() const;
68 //==============================================================================
69 /** Reads data from the pipe.
71 This will block until another thread has written enough data into the pipe to fill
72 the number of bytes specified, or until another thread calls the cancelPendingReads()
75 If the operation fails, it returns -1, otherwise, it will return the number of
78 If timeOutMilliseconds is less than zero, it will wait indefinitely, otherwise
79 this is a maximum timeout for reading from the pipe.
81 int read (void* destBuffer
, int maxBytesToRead
, int timeOutMilliseconds
);
83 /** Writes some data to the pipe.
84 @returns the number of bytes written, or -1 on failure.
86 int write (const void* sourceBuffer
, int numBytesToWrite
, int timeOutMilliseconds
);
89 //==============================================================================
90 JUCE_PUBLIC_IN_DLL_BUILD (class Pimpl
)
91 std::unique_ptr
<Pimpl
> pimpl
;
92 String currentPipeName
;
95 bool openInternal (const String
& pipeName
, bool createPipe
, bool mustNotExist
);
97 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NamedPipe
)