Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 2497

Show
Ignore:
Timestamp:
08/20/07 00:58:37 (1 year ago)
Author:
kris
Message:

changes for the commit/dispose/close issue:

- conduit.close() now renamed conduit.disconnect()
- conduit.dispose() renamed to conduit.close()

The close() method now invokes flush() and commit() before invoking disconnect(). Every conduit has to implement disconnect(), whereas close() is a utility in the base class.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/example/conduits/FileBucket.d

    r2490 r2497  
    222222                if (file) 
    223223                   { 
    224                    file.close ()
     224                   file.disconnect
    225225                   file = null; 
    226226                   map = null; 
  • trunk/example/conduits/filecat.d

    r2490 r2497  
    2020 
    2121           // flush output and close 
    22            dst.dispose; 
     22           dst.close; 
    2323           } 
    2424        else 
  • trunk/example/networking/selector.d

    r2490 r2497  
    278278        } 
    279279 
    280         serverSocket.socket().close()
     280        serverSocket.socket().disconnect
    281281    } 
    282282    catch (SelectorException e) 
     
    298298    clientThread.join(); 
    299299 
    300     selector.close()
     300    selector.close
    301301} 
    302302 
  • trunk/tango/io/Buffer.d

    r2490 r2497  
    12101210        ***********************************************************************/ 
    12111211 
    1212         final void dispose () 
     1212        final void dispose1 () 
    12131213        { 
    12141214                if (sink) 
     
    12161216                   flush; 
    12171217                   commit; 
    1218                    sink.conduit.dispose (false);  
     1218                   sink.conduit.disconnect;  
    12191219                   } 
    12201220                delete this; 
  • trunk/tango/io/Conduit.d

    r2490 r2497  
    8787        /*********************************************************************** 
    8888 
    89                 Close this conduit 
    90  
    91         ***********************************************************************/ 
    92  
    93         abstract void close (); 
     89                Disconnect this conduit 
     90 
     91        ***********************************************************************/ 
     92 
     93        abstract void disconnect (); 
    9494 
    9595        /*********************************************************************** 
     
    153153        /*********************************************************************** 
    154154 
    155                 Dispose of this conduit 
     155                Close this conduit 
    156156                 
    157157                Remarks: 
    158                 Dispose flushes & commits any filters, closes the conduit,  
    159                 and deletes it. This should be used in preference to close() 
    160  
    161         ***********************************************************************/ 
    162  
    163         final void dispose (bool clean=true) 
    164         { 
    165                 if (clean) 
    166                    { 
    167                    sink.flush; 
    168                    sink.commit; 
    169                    } 
    170  
    171                 this.close; 
    172                 delete this; 
     158                Close flushes & commits any filters, and disconnects the  
     159                conduit. 
     160 
     161        ***********************************************************************/ 
     162 
     163        final void close () 
     164        { 
     165                sink.flush; 
     166                sink.commit; 
     167                this.disconnect; 
    173168        } 
    174169 
  • trunk/tango/io/DeviceConduit.d

    r2490 r2497  
    9696                /*************************************************************** 
    9797 
    98                         Close the underlying file 
    99  
    100                 ***************************************************************/ 
    101  
    102                 override void close () 
     98                        Release the underlying file 
     99 
     100                ***************************************************************/ 
     101 
     102                override void disconnect () 
    103103                { 
    104104                        if (handle) 
     
    199199                /*************************************************************** 
    200200 
    201                         Close the underlying file 
    202  
    203                 ***************************************************************/ 
    204  
    205                 override void close () 
     201                        Release the underlying file 
     202 
     203                ***************************************************************/ 
     204 
     205                override void disconnect () 
    206206                { 
    207207                        if (handle) 
  • trunk/tango/io/File.d

    r2491 r2497  
    8282                scope conduit = new FileConduit (path_);   
    8383                scope (exit) 
    84                        conduit.dispose; 
     84                       conduit.close; 
    8585 
    8686                // allocate enough space for the entire file 
     
    126126                scope conduit = new FileConduit (path_, style);   
    127127                scope (exit) 
    128                        conduit.dispose; 
     128                       conduit.close; 
    129129 
    130130                conduit.output.write (content); 
  • trunk/tango/io/MemoryConduit.d

    r2490 r2497  
    108108        /*********************************************************************** 
    109109 
    110                 Close this conduit 
     110                Release resources 
    111111 
    112112        ***********************************************************************/ 
    113113 
    114         override void close () {} 
     114        override void disconnect () {} 
    115115} 
    116116 
  • trunk/tango/io/UnicodeFile.d

    r2491 r2497  
    171171                scope conduit = new FileConduit (path_);   
    172172                scope (exit) 
    173                        conduit.dispose; 
     173                       conduit.close; 
    174174 
    175175                // allocate enough space for the entire file 
     
    226226                scope conduit = new FileConduit (path_, style);   
    227227                scope (exit) 
    228                        conduit.dispose; 
     228                       conduit.close; 
    229229 
    230230                if (writeBom) 
  • trunk/tango/io/model/IConduit.d

    r2490 r2497  
    9898        ***********************************************************************/ 
    9999 
     100        abstract void disconnect (); 
     101 
     102        /*********************************************************************** 
     103 
     104                Close this conduit 
     105                 
     106                Remarks: 
     107                Close flushes & commits any filters, and disconnects the  
     108                conduit. 
     109 
     110        ***********************************************************************/ 
     111 
    100112        abstract void close (); 
    101  
    102         /*********************************************************************** 
    103  
    104                 Dispose of this conduit 
    105                  
    106                 Remarks: 
    107                 Dispose flushes & commits any filters, closes the conduit,  
    108                 and deletes it. This should be used in preference to close() 
    109  
    110         ***********************************************************************/ 
    111  
    112         abstract void dispose (bool clean=true); 
    113113 
    114114        /*********************************************************************** 
  • trunk/tango/net/Socket.d

    r2398 r2497  
    722722        { 
    723723                if (this.sock) 
    724                     close()
     724                    this.disconnect
    725725 
    726726                if (sock is sock.init) 
     
    10231023        ***********************************************************************/ 
    10241024 
    1025         void close () 
     1025        void disconnect () 
    10261026        { 
    10271027                if (sock != sock.init) 
  • trunk/tango/net/SocketConduit.d

    r2490 r2497  
    205205        /*********************************************************************** 
    206206 
    207                 Deallocate this SocketConduit when it is been closed. 
    208  
    209                 Note that one should always close a SocketConduit under 
    210                 normal conditions, and generally invoke shutdown on all 
    211                 connected sockets beforehand 
    212  
    213         ***********************************************************************/ 
    214  
    215         override void close () 
    216         { 
    217                 socket_.close
     207                Release this SocketConduit 
     208 
     209                Note that one should always disconnect a SocketConduit  
     210                under normal conditions, and generally invoke shutdown  
     211                on all connected sockets beforehand 
     212 
     213        ***********************************************************************/ 
     214 
     215        override void disconnect () 
     216        { 
     217                socket_.disconnect
    218218 
    219219                // deallocate if this came from the free-list, 
  • trunk/tango/net/cluster/tina/Cluster.d

    r2467 r2497  
    10901090                final void close () 
    10911091                { 
    1092                         conduit_.close
     1092                        conduit_.disconnect
    10931093                } 
    10941094 
  • trunk/tango/net/cluster/tina/ClusterThread.d

    r2465 r2497  
    142142 
    143143                // make sure we close the conduit 
    144                 buffer.conduit.close
     144                buffer.conduit.disconnect
    145145        } 
    146146} 
  • trunk/tango/net/cluster/tina/QueueFile.d

    r2465 r2497  
    146146        { 
    147147                if (conduit) 
    148                     conduit.close
     148                    conduit.disconnect
    149149                conduit = null; 
    150150        } 
  • trunk/tango/net/ftp/FtpClient.d

    r2465 r2497  
    285285                // Shutdown the socket... 
    286286                this.socket.shutdown(SocketShutdown.BOTH); 
    287                 this.socket.close(); 
     287                this.socket.disconnect(); 
    288288 
    289289                // Clear out everything. 
     
    492492                // Close the socket, whether we were listening or not. 
    493493                data.shutdown(SocketShutdown.BOTH); 
    494                 data.close(); 
     494                data.disconnect(); 
    495495            } 
    496496 
     
    519519        // Close the socket.  This tells the server we're done (EOF.) 
    520520        data.shutdown(SocketShutdown.BOTH); 
    521         data.close(); 
     521        data.disconnect(); 
    522522 
    523523        // We shouldn't get a 250 in STREAM mode. 
     
    635635                // We don't need the listener anymore. 
    636636                data.shutdown(SocketShutdown.BOTH); 
    637                 data.close(); 
     637                data.disconnect(); 
    638638 
    639639                // This is the actual socket. 
     
    753753        scope (exit) 
    754754            { 
    755                 file.close(); 
     755                file.disconnect(); 
    756756                delete file; 
    757757            } 
     
    900900        scope (exit) 
    901901            { 
    902                 file.close(); 
     902                file.disconnect(); 
    903903                delete file; 
    904904            } 
  • trunk/tango/net/ftp/Telnet.d

    r2465 r2497  
    228228                        { 
    229229                                s.shutdown(SocketShutdown.BOTH); 
    230                                 s.close(); 
     230                                s.disconnect(); 
    231231 
    232232                                delete s; 
  • trunk/tango/net/http/HttpClient.d

    r2495 r2497  
    270270                   { 
    271271                   socket.shutdown; 
    272                    socket.close
     272                   socket.disconnect
    273273                   socket = null; 
    274274                   } 
  • trunk/tango/util/log/FileAppender.d

    r2304 r2497  
    143143                if (conduit_) 
    144144                   { 
    145                    conduit_.close()
     145                   conduit_.disconnect
    146146                   conduit_ = null; 
    147147                   } 
  • trunk/tango/util/log/SocketAppender.d

    r2304 r2497  
    121121        { 
    122122                if (buffer) 
    123                     buffer.conduit.close
     123                    buffer.conduit.disconnect
    124124                buffer = null; 
    125125        }