Author: mturk
Date: Mon Nov 23 09:10:51 2009
New Revision: 883287
URL: http://svn.apache.org/viewvc?rev=883287&view=rev
Log:
Use read and write instead parent and child for pipe modes
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Pipe.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/PipeIoMode.java
commons/sandbox/runtime/trunk/src/main/native/include/acr_pipe.h
commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Pipe.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Pipe.java?rev=883287&r1=883286&r2=883287&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Pipe.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Pipe.java
Mon Nov 23 09:10:51 2009
@@ -34,14 +34,19 @@
import org.apache.commons.runtime.util.StringManager;
/**
- * Provides static methods for the creation, copying, deletion,
- * moving and opening of pipes.
+ * Pipe represents unidirectional data channel that can be used for
+ * interprocess communication.
* <p>
+ * Data channel consists of two {...@code Pipe} instances that represent
+ * read and write end of the channel.
* </p>
*/
public final class Pipe implements Device, Syncable
{
+ static private final int RD = 0x0100;
+ static private final int WR = 0x0200;
+
private Descriptor fd;
private String name;
private PipeIoMode mode;
@@ -142,6 +147,20 @@
}
/**
+ * Test if this {...@code Pipe} is write end of this pipe
+ * channel.
+ * @return {...@code true} if {...@code this} pipe instance is write end
+ * of the pipe channel.
+ */
+ public final boolean isWriteEnd()
+ {
+ if ((type & WR) == WR)
+ return true;
+ else
+ return false;
+ }
+
+ /**
* Close this pipe.
* @see java.io.Closeable#close()
* @throws IOException if an I/O error occurs.
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/PipeIoMode.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/PipeIoMode.java?rev=883287&r1=883286&r2=883287&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/PipeIoMode.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/PipeIoMode.java
Mon Nov 23 09:10:51 2009
@@ -28,16 +28,14 @@
FULL_BLOCK( 1),
/** Make read/write non blocking. */
FULL_NONBLOCK( 2),
- /** Block the parent while accessing the {...@code Pipe}.
- * This corresponds to blocking the read side of the pipe.
+ /** Block the read end of the {...@code Pipe} channel.
* If set the write side of the pipe in nonblocking.
*/
- PARENT_BLOCK( 3),
- /** Block the child while accessing the {...@code Pipe}.
- * This corresponds to blocking the write side of the pipe.
+ READ_BLOCK( 3),
+ /** Block the erite end of the {...@code Pipe} channel.
* If set the read side of the pipe in nonblocking.
*/
- CHILD_BLOCK( 4);
+ WRITE_BLOCK( 4);
private int value;
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_pipe.h
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_pipe.h?rev=883287&r1=883286&r2=883287&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_pipe.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_pipe.h Mon Nov 23
09:10:51 2009
@@ -35,11 +35,11 @@
*/
#define ACR_PIPE_FULL_BLOCK 1
#define ACR_PIPE_FULL_NONBLOCK 2
-#define ACR_PIPE_PARENT_BLOCK 3
-#define ACR_PIPE_CHILD_BLOCK 4
+#define ACR_PIPE_READ_BLOCK 3
+#define ACR_PIPE_WRITE_BLOCK 4
-#define ACR_PIPE_IN 0x0100
-#define ACR_PIPE_OUT 0x0200
+#define ACR_PIPE_RD 0x0100
+#define ACR_PIPE_WR 0x0200
/**
* Create new Pipe object.
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c?rev=883287&r1=883286&r2=883287&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pipe.c Mon Nov 23
09:10:51 2009
@@ -167,8 +167,8 @@
acr_file_t *fp = NULL;
if (ff == ACR_PIPE_FULL_NONBLOCK ||
- (ff == ACR_PIPE_CHILD_BLOCK && (flags & ACR_PIPE_IN)) ||
- (ff == ACR_PIPE_PARENT_BLOCK && (flags & ACR_PIPE_OUT))) {
+ (ff == ACR_PIPE_WRITE_BLOCK && (flags & ACR_PIPE_RD)) ||
+ (ff == ACR_PIPE_READ_BLOCK && (flags & ACR_PIPE_WR))) {
if ((rc = acr_nonblock(fd, 1)))
goto finally;
}
@@ -182,8 +182,8 @@
fp->flags = flags;
fp->type = ACR_FT_PIPE;
if (ff == ACR_PIPE_FULL_NONBLOCK ||
- (ff == ACR_PIPE_CHILD_BLOCK && (flags & ACR_PIPE_IN)) ||
- (ff == ACR_PIPE_PARENT_BLOCK && (flags & ACR_PIPE_OUT))) {
+ (ff == ACR_PIPE_WRITE_BLOCK && (flags & ACR_PIPE_RD)) ||
+ (ff == ACR_PIPE_READ_BLOCK && (flags & ACR_PIPE_WR))) {
fp->blocking = BLK_OFF;
fp->timeout = 0;
}
@@ -239,11 +239,11 @@
close(pd[0]);
close(pd[1]);
}
- rc = do_popen(_E, pd[0], flags & ACR_PIPE_IN, &fd[0]);
+ rc = do_popen(_E, pd[0], flags & ACR_PIPE_RD, &fd[0]);
if (rc) {
goto cleanup;
}
- rc = do_popen(_E, pd[1], flags & ACR_PIPE_OUT, &fd[1]);
+ rc = do_popen(_E, pd[1], flags & ACR_PIPE_WR, &fd[1]);
if (rc) {
/* ### fd[0] will be closed by GC ?
*/