Changeset 23:e6c4c31ce833 in xplcommon


Ignore:
Timestamp:
01/02/13 06:50:19 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Eliminated the double storage of the Overlappable instances in the children of Completer

Location:
src/xplcommon/win32
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/xplcommon/win32/LocalAcceptor.cc

    r22 r23  
    4040LocalAcceptor::LocalAcceptor(LocalServerSocketBase* socket, const char* name) :
    4141    Completer(socket),
    42     socket(*socket),
    4342    accepted(false)
    4443{
     
    5857    }
    5958
     59    LocalServerSocketBase& socket = getServerSocket();
    6060    if (!socket.createNamedPipe(path)) {
    6161        return false;
  • src/xplcommon/win32/LocalAcceptor.h

    r22 r23  
    5252private:
    5353    /**
    54      * The local server socket for which we are accepting connections.
    55      */
    56     LocalServerSocketBase& socket;
    57 
    58     /**
    5954     * The path of the pipe to accept.
    6055     */
     
    7166     */
    7267    LocalAcceptor(LocalServerSocketBase* socket, const char* name);
     68
     69    /**
     70     * Get the socket.
     71     *
     72     * It returns the overlappable from the Completer part, knowing
     73     * that it must be a LocalServerSocketBase.
     74     */
     75    LocalServerSocketBase& getServerSocket() const;
    7376
    7477public:
     
    130133//------------------------------------------------------------------------------
    131134
     135inline LocalServerSocketBase& LocalAcceptor::getServerSocket() const
     136{
     137    return static_cast<LocalServerSocketBase&>(overlappable);
     138}
     139
     140//------------------------------------------------------------------------------
     141
    132142inline LocalSocket* LocalAcceptor::getSocket(Waiter* waiter,
    133143                                             size_t readingCapacity,
     
    136146    if (!accepted) return 0;
    137147
    138     LocalSocket* s = new LocalSocket(waiter, socket.releaseHandle(),
     148    LocalSocket* s = new LocalSocket(waiter, getServerSocket().releaseHandle(),
    139149                                     readingCapacity, writingCapacity);
    140150    accepted = false;
    141151    return s;
    142152}
     153
    143154//------------------------------------------------------------------------------
    144155
     
    146157                                             size_t writingCapacity)
    147158{
    148     return getSocket(socket.waiter, readingCapacity, writingCapacity);
     159    return getSocket(getServerSocket().waiter,
     160                     readingCapacity, writingCapacity);
    149161}
    150162
     
    153165inline const ::xplcommon::Failable& LocalAcceptor::getFailable() const
    154166{
    155     return socket;
     167    return overlappable;
    156168}
    157169
     
    160172inline ::xplcommon::Failable& LocalAcceptor::getFailable()
    161173{
    162     return socket;
     174    return overlappable;
    163175}
    164176
  • src/xplcommon/win32/ReadingBuffer.cc

    r22 r23  
    5353    }
    5454
     55    BufferedStream& stream = getStream();
    5556    ssize_t numRead = stream.read(getData(), getCapacity(), overlapped);
    5657    if (numRead<0) {
  • src/xplcommon/win32/StreamBuffer.h

    r21 r23  
    5252protected:
    5353    /**
    54      * The buffered stream this stream buffer belongs to.
    55      */
    56     BufferedStream& stream;
    57 
    58 protected:
    59     /**
    6054     * Construct the stream buffer with the given capacity and for the
    6155     * given stream.
    6256     */
    6357    StreamBuffer(size_t capacity, BufferedStream* stream);
     58
     59    /**
     60     * Get the stream.
     61     *
     62     * This just casts the overlappable of the Completer part knowing
     63     * that it must be a BufferedStream
     64     */
     65    BufferedStream& getStream() const;
    6466
    6567private:
     
    8385inline StreamBuffer::StreamBuffer(size_t capacity, BufferedStream* stream) :
    8486    Buffer(capacity),
    85     Completer(stream),
    86     stream(*stream)
     87    Completer(stream)
    8788{
     89}
     90
     91//------------------------------------------------------------------------------
     92
     93inline BufferedStream& StreamBuffer::getStream() const
     94{
     95    return static_cast<BufferedStream&>(overlappable);
    8896}
    8997
     
    92100inline const ::xplcommon::Failable& StreamBuffer::getFailable() const
    93101{
    94     return stream;
     102    return overlappable;
    95103}
    96104
     
    99107inline ::xplcommon::Failable& StreamBuffer::getFailable()
    100108{
    101     return stream;
     109    return overlappable;
    102110}
    103111
  • src/xplcommon/win32/WritingBuffer.cc

    r22 r23  
    5151    }
    5252
     53    BufferedStream& stream = getStream();
    5354    result = stream.write(getData(), getLength(), overlapped);
    5455    if (result) {
Note: See TracChangeset for help on using the changeset viewer.