OpenShot Library | libopenshot-audio 0.2.0
juce_NamedPipe.h
1
2/** @weakgroup juce_core-network
3 * @{
4 */
5/*
6 ==============================================================================
7
8 This file is part of the JUCE library.
9 Copyright (c) 2017 - ROLI Ltd.
10
11 JUCE is an open source library subject to commercial or open-source
12 licensing.
13
14 The code included in this file is provided under the terms of the ISC license
15 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
16 To use, copy, modify, and/or distribute this software for any purpose with or
17 without fee is hereby granted provided that the above copyright notice and
18 this permission notice appear in all copies.
19
20 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22 DISCLAIMED.
23
24 ==============================================================================
25*/
26
27namespace juce
28{
29
30//==============================================================================
31/**
32 A cross-process pipe that can have data written to and read from it.
33
34 Two processes can use NamedPipe objects to exchange blocks of data.
35
36 @see InterprocessConnection
37
38 @tags{Core}
39*/
41{
42public:
43 //==============================================================================
44 /** Creates a NamedPipe. */
45 NamedPipe();
46
47 /** Destructor. */
48 ~NamedPipe();
49
50 //==============================================================================
51 /** Tries to open a pipe that already exists.
52 Returns true if it succeeds.
53 */
54 bool openExisting (const String& pipeName);
55
56 /** Tries to create a new pipe.
57 Returns true if it succeeds.
58 If mustNotExist is true then it will fail if a pipe is already
59 open with the same name.
60 */
61 bool createNewPipe (const String& pipeName, bool mustNotExist = false);
62
63 /** Closes the pipe, if it's open. */
64 void close();
65
66 /** True if the pipe is currently open. */
67 bool isOpen() const;
68
69 /** Returns the last name that was used to try to open this pipe. */
70 String getName() const;
71
72 //==============================================================================
73 /** Reads data from the pipe.
74
75 This will block until another thread has written enough data into the pipe to fill
76 the number of bytes specified, or until another thread calls the cancelPendingReads()
77 method.
78
79 If the operation fails, it returns -1, otherwise, it will return the number of
80 bytes read.
81
82 If timeOutMilliseconds is less than zero, it will wait indefinitely, otherwise
83 this is a maximum timeout for reading from the pipe.
84 */
86
87 /** Writes some data to the pipe.
88 @returns the number of bytes written, or -1 on failure.
89 */
91
92private:
93 //==============================================================================
94 JUCE_PUBLIC_IN_DLL_BUILD (class Pimpl)
95 std::unique_ptr<Pimpl> pimpl;
96 String currentPipeName;
97 ReadWriteLock lock;
98
99 bool openInternal (const String& pipeName, bool createPipe, bool mustNotExist);
100
101 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NamedPipe)
102};
103
104} // namespace juce
105
106/** @}*/
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:60
A cross-process pipe that can have data written to and read from it.
int write(const void *sourceBuffer, int numBytesToWrite, int timeOutMilliseconds)
Writes some data to the pipe.
int read(void *destBuffer, int maxBytesToRead, int timeOutMilliseconds)
Reads data from the pipe.
void close()
Closes the pipe, if it's open.
A critical section that allows multiple simultaneous readers.
The JUCE String class!
Definition juce_String.h:43
#define JUCE_API
This macro is added to all JUCE public class declarations.