Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsIPipe.idl File Reference
import "nsIAsyncInputStream.idl";
import "nsIAsyncOutputStream.idl";

Go to the source code of this file.

Classes

interface  nsIPipe
 nsIPipe represents an in-process buffer that can be read using nsIInputStream and written using nsIOutputStream. More...
interface  nsISearchableInputStream
 XXX this interface doesn't really belong in here. More...

Functions

NS_COM nsresult NS_NewPipe2 (nsIAsyncInputStream **pipeIn, nsIAsyncOutputStream **pipeOut, PRBool nonBlockingInput=PR_FALSE, PRBool nonBlockingOutput=PR_FALSE, PRUint32 segmentSize=0, PRUint32 segmentCount=0, nsIMemory *segmentAlloc=nsnull)
 NS_NewPipe2.
nsresult NS_NewPipe (nsIInputStream **pipeIn, nsIOutputStream **pipeOut, PRUint32 segmentSize=0, PRUint32 maxSize=0, PRBool nonBlockingInput=PR_FALSE, PRBool nonBlockingOutput=PR_FALSE, nsIMemory *segmentAlloc=nsnull)
 NS_NewPipe.

Function Documentation

nsresult NS_NewPipe ( nsIInputStream **  pipeIn,
nsIOutputStream **  pipeOut,
PRUint32  segmentSize = 0,
PRUint32  maxSize = 0,
PRBool  nonBlockingInput = PR_FALSE,
PRBool  nonBlockingOutput = PR_FALSE,
nsIMemory segmentAlloc = nsnull 
) [inline]

NS_NewPipe.

Preserved for backwards compatibility. Plus, this interface is more amiable in certain contexts (e.g., when you don't need the pipe's async capabilities).

Parameters:
pipeInresulting input end of the pipe
pipeOutresulting output end of the pipe
segmentSizespecifies the segment size in bytes (pass 0 to use default value)
maxSizespecifies the max size of the pipe (pass 0 to use default value) number of segments is maxSize / segmentSize, and maxSize must be a multiple of segmentSize. passing PR_UINT32_MAX here causes the pipe to have "infinite" space. this mode can be useful in some cases, but should always be used with caution. the default value for this parameter is a finite value.
nonBlockingInputtrue specifies non-blocking input stream behavior
nonBlockingOutputtrue specifies non-blocking output stream behavior
segmentAllocpass reference to nsIMemory to have all pipe allocations use this allocator (pass null to use the default allocator)

Definition at line 186 of file nsIPipe.idl.

{
    PRUint32 segmentCount;
    if (segmentSize == 0)
        segmentCount = 0; // use default
    else
        segmentCount = maxSize / segmentSize;

    nsIAsyncInputStream *in;
    nsIAsyncOutputStream *out;
    nsresult rv = NS_NewPipe2(&in, &out, nonBlockingInput, nonBlockingOutput,
                              segmentSize, segmentCount, segmentAlloc);
    if (NS_FAILED(rv)) return rv;

    *pipeIn = in;
    *pipeOut = out;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_COM nsresult NS_NewPipe2 ( nsIAsyncInputStream **  pipeIn,
nsIAsyncOutputStream **  pipeOut,
PRBool  nonBlockingInput = PR_FALSE,
PRBool  nonBlockingOutput = PR_FALSE,
PRUint32  segmentSize = 0,
PRUint32  segmentCount = 0,
nsIMemory segmentAlloc = nsnull 
)

NS_NewPipe2.

This function supercedes NS_NewPipe. It differs from NS_NewPipe in two major ways: (1) returns nsIAsyncInputStream and nsIAsyncOutputStream, so it is not necessary to QI in order to access these interfaces. (2) the size of the pipe is determined by the number of segments times the size of each segment.

Parameters:
pipeInresulting input end of the pipe
pipeOutresulting output end of the pipe
nonBlockingInputtrue specifies non-blocking input stream behavior
nonBlockingOutputtrue specifies non-blocking output stream behavior
segmentSizespecifies the segment size in bytes (pass 0 to use default value)
segmentCountspecifies the max number of segments (pass 0 to use default value) passing PR_UINT32_MAX here causes the pipe to have "infinite" space. this mode can be useful in some cases, but should always be used with caution. the default value for this parameter is a finite value.
segmentAllocpass reference to nsIMemory to have all pipe allocations use this allocator (pass null to use the default allocator)

Definition at line 1243 of file nsPipe3.cpp.

{
    nsresult rv;

    nsPipe *pipe = new nsPipe();
    if (!pipe)
        return NS_ERROR_OUT_OF_MEMORY;

    rv = pipe->Init(nonBlockingInput,
                    nonBlockingOutput,
                    segmentSize,
                    segmentCount,
                    segmentAlloc);
    if (NS_FAILED(rv)) {
        NS_ADDREF(pipe);
        NS_RELEASE(pipe);
        return rv;
    }

    pipe->GetInputStream(pipeIn);
    pipe->GetOutputStream(pipeOut);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function: