 |
Changeset 2497
- 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
| r2490 |
r2497 |
|
| 222 | 222 | if (file) |
|---|
| 223 | 223 | { |
|---|
| 224 | | file.close (); |
|---|
| | 224 | file.disconnect; |
|---|
| 225 | 225 | file = null; |
|---|
| 226 | 226 | map = null; |
|---|
| r2490 |
r2497 |
|
| 20 | 20 | |
|---|
| 21 | 21 | // flush output and close |
|---|
| 22 | | dst.dispose; |
|---|
| | 22 | dst.close; |
|---|
| 23 | 23 | } |
|---|
| 24 | 24 | else |
|---|
| r2490 |
r2497 |
|
| 278 | 278 | } |
|---|
| 279 | 279 | |
|---|
| 280 | | serverSocket.socket().close(); |
|---|
| | 280 | serverSocket.socket().disconnect; |
|---|
| 281 | 281 | } |
|---|
| 282 | 282 | catch (SelectorException e) |
|---|
| … | … | |
| 298 | 298 | clientThread.join(); |
|---|
| 299 | 299 | |
|---|
| 300 | | selector.close(); |
|---|
| | 300 | selector.close; |
|---|
| 301 | 301 | } |
|---|
| 302 | 302 | |
|---|
| r2490 |
r2497 |
|
| 1210 | 1210 | ***********************************************************************/ |
|---|
| 1211 | 1211 | |
|---|
| 1212 | | final void dispose () |
|---|
| | 1212 | final void dispose1 () |
|---|
| 1213 | 1213 | { |
|---|
| 1214 | 1214 | if (sink) |
|---|
| … | … | |
| 1216 | 1216 | flush; |
|---|
| 1217 | 1217 | commit; |
|---|
| 1218 | | sink.conduit.dispose (false); |
|---|
| | 1218 | sink.conduit.disconnect; |
|---|
| 1219 | 1219 | } |
|---|
| 1220 | 1220 | delete this; |
|---|
| r2490 |
r2497 |
|
| 87 | 87 | /*********************************************************************** |
|---|
| 88 | 88 | |
|---|
| 89 | | Close this conduit |
|---|
| 90 | | |
|---|
| 91 | | ***********************************************************************/ |
|---|
| 92 | | |
|---|
| 93 | | abstract void close (); |
|---|
| | 89 | Disconnect this conduit |
|---|
| | 90 | |
|---|
| | 91 | ***********************************************************************/ |
|---|
| | 92 | |
|---|
| | 93 | abstract void disconnect (); |
|---|
| 94 | 94 | |
|---|
| 95 | 95 | /*********************************************************************** |
|---|
| … | … | |
| 153 | 153 | /*********************************************************************** |
|---|
| 154 | 154 | |
|---|
| 155 | | Dispose of this conduit |
|---|
| | 155 | Close this conduit |
|---|
| 156 | 156 | |
|---|
| 157 | 157 | 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; |
|---|
| 173 | 168 | } |
|---|
| 174 | 169 | |
|---|
| r2490 |
r2497 |
|
| 96 | 96 | /*************************************************************** |
|---|
| 97 | 97 | |
|---|
| 98 | | Close the underlying file |
|---|
| 99 | | |
|---|
| 100 | | ***************************************************************/ |
|---|
| 101 | | |
|---|
| 102 | | override void close () |
|---|
| | 98 | Release the underlying file |
|---|
| | 99 | |
|---|
| | 100 | ***************************************************************/ |
|---|
| | 101 | |
|---|
| | 102 | override void disconnect () |
|---|
| 103 | 103 | { |
|---|
| 104 | 104 | if (handle) |
|---|
| … | … | |
| 199 | 199 | /*************************************************************** |
|---|
| 200 | 200 | |
|---|
| 201 | | Close the underlying file |
|---|
| 202 | | |
|---|
| 203 | | ***************************************************************/ |
|---|
| 204 | | |
|---|
| 205 | | override void close () |
|---|
| | 201 | Release the underlying file |
|---|
| | 202 | |
|---|
| | 203 | ***************************************************************/ |
|---|
| | 204 | |
|---|
| | 205 | override void disconnect () |
|---|
| 206 | 206 | { |
|---|
| 207 | 207 | if (handle) |
|---|
| r2491 |
r2497 |
|
| 82 | 82 | scope conduit = new FileConduit (path_); |
|---|
| 83 | 83 | scope (exit) |
|---|
| 84 | | conduit.dispose; |
|---|
| | 84 | conduit.close; |
|---|
| 85 | 85 | |
|---|
| 86 | 86 | // allocate enough space for the entire file |
|---|
| … | … | |
| 126 | 126 | scope conduit = new FileConduit (path_, style); |
|---|
| 127 | 127 | scope (exit) |
|---|
| 128 | | conduit.dispose; |
|---|
| | 128 | conduit.close; |
|---|
| 129 | 129 | |
|---|
| 130 | 130 | conduit.output.write (content); |
|---|
| r2490 |
r2497 |
|
| 108 | 108 | /*********************************************************************** |
|---|
| 109 | 109 | |
|---|
| 110 | | Close this conduit |
|---|
| | 110 | Release resources |
|---|
| 111 | 111 | |
|---|
| 112 | 112 | ***********************************************************************/ |
|---|
| 113 | 113 | |
|---|
| 114 | | override void close () {} |
|---|
| | 114 | override void disconnect () {} |
|---|
| 115 | 115 | } |
|---|
| 116 | 116 | |
|---|
| r2491 |
r2497 |
|
| 171 | 171 | scope conduit = new FileConduit (path_); |
|---|
| 172 | 172 | scope (exit) |
|---|
| 173 | | conduit.dispose; |
|---|
| | 173 | conduit.close; |
|---|
| 174 | 174 | |
|---|
| 175 | 175 | // allocate enough space for the entire file |
|---|
| … | … | |
| 226 | 226 | scope conduit = new FileConduit (path_, style); |
|---|
| 227 | 227 | scope (exit) |
|---|
| 228 | | conduit.dispose; |
|---|
| | 228 | conduit.close; |
|---|
| 229 | 229 | |
|---|
| 230 | 230 | if (writeBom) |
|---|
| r2490 |
r2497 |
|
| 98 | 98 | ***********************************************************************/ |
|---|
| 99 | 99 | |
|---|
| | 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 | |
|---|
| 100 | 112 | 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); |
|---|
| 113 | 113 | |
|---|
| 114 | 114 | /*********************************************************************** |
|---|
| r2398 |
r2497 |
|
| 722 | 722 | { |
|---|
| 723 | 723 | if (this.sock) |
|---|
| 724 | | close(); |
|---|
| | 724 | this.disconnect; |
|---|
| 725 | 725 | |
|---|
| 726 | 726 | if (sock is sock.init) |
|---|
| … | … | |
| 1023 | 1023 | ***********************************************************************/ |
|---|
| 1024 | 1024 | |
|---|
| 1025 | | void close () |
|---|
| | 1025 | void disconnect () |
|---|
| 1026 | 1026 | { |
|---|
| 1027 | 1027 | if (sock != sock.init) |
|---|
| r2490 |
r2497 |
|
| 205 | 205 | /*********************************************************************** |
|---|
| 206 | 206 | |
|---|
| 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; |
|---|
| 218 | 218 | |
|---|
| 219 | 219 | // deallocate if this came from the free-list, |
|---|
| r2467 |
r2497 |
|
| 1090 | 1090 | final void close () |
|---|
| 1091 | 1091 | { |
|---|
| 1092 | | conduit_.close; |
|---|
| | 1092 | conduit_.disconnect; |
|---|
| 1093 | 1093 | } |
|---|
| 1094 | 1094 | |
|---|
| r2465 |
r2497 |
|
| 142 | 142 | |
|---|
| 143 | 143 | // make sure we close the conduit |
|---|
| 144 | | buffer.conduit.close; |
|---|
| | 144 | buffer.conduit.disconnect; |
|---|
| 145 | 145 | } |
|---|
| 146 | 146 | } |
|---|
| r2465 |
r2497 |
|
| 146 | 146 | { |
|---|
| 147 | 147 | if (conduit) |
|---|
| 148 | | conduit.close; |
|---|
| | 148 | conduit.disconnect; |
|---|
| 149 | 149 | conduit = null; |
|---|
| 150 | 150 | } |
|---|
| r2465 |
r2497 |
|
| 285 | 285 | // Shutdown the socket... |
|---|
| 286 | 286 | this.socket.shutdown(SocketShutdown.BOTH); |
|---|
| 287 | | this.socket.close(); |
|---|
| | 287 | this.socket.disconnect(); |
|---|
| 288 | 288 | |
|---|
| 289 | 289 | // Clear out everything. |
|---|
| … | … | |
| 492 | 492 | // Close the socket, whether we were listening or not. |
|---|
| 493 | 493 | data.shutdown(SocketShutdown.BOTH); |
|---|
| 494 | | data.close(); |
|---|
| | 494 | data.disconnect(); |
|---|
| 495 | 495 | } |
|---|
| 496 | 496 | |
|---|
| … | … | |
| 519 | 519 | // Close the socket. This tells the server we're done (EOF.) |
|---|
| 520 | 520 | data.shutdown(SocketShutdown.BOTH); |
|---|
| 521 | | data.close(); |
|---|
| | 521 | data.disconnect(); |
|---|
| 522 | 522 | |
|---|
| 523 | 523 | // We shouldn't get a 250 in STREAM mode. |
|---|
| … | … | |
| 635 | 635 | // We don't need the listener anymore. |
|---|
| 636 | 636 | data.shutdown(SocketShutdown.BOTH); |
|---|
| 637 | | data.close(); |
|---|
| | 637 | data.disconnect(); |
|---|
| 638 | 638 | |
|---|
| 639 | 639 | // This is the actual socket. |
|---|
| … | … | |
| 753 | 753 | scope (exit) |
|---|
| 754 | 754 | { |
|---|
| 755 | | file.close(); |
|---|
| | 755 | file.disconnect(); |
|---|
| 756 | 756 | delete file; |
|---|
| 757 | 757 | } |
|---|
| … | … | |
| 900 | 900 | scope (exit) |
|---|
| 901 | 901 | { |
|---|
| 902 | | file.close(); |
|---|
| | 902 | file.disconnect(); |
|---|
| 903 | 903 | delete file; |
|---|
| 904 | 904 | } |
|---|
| r2465 |
r2497 |
|
| 228 | 228 | { |
|---|
| 229 | 229 | s.shutdown(SocketShutdown.BOTH); |
|---|
| 230 | | s.close(); |
|---|
| | 230 | s.disconnect(); |
|---|
| 231 | 231 | |
|---|
| 232 | 232 | delete s; |
|---|
| r2495 |
r2497 |
|
| 270 | 270 | { |
|---|
| 271 | 271 | socket.shutdown; |
|---|
| 272 | | socket.close; |
|---|
| | 272 | socket.disconnect; |
|---|
| 273 | 273 | socket = null; |
|---|
| 274 | 274 | } |
|---|
| r2304 |
r2497 |
|
| 143 | 143 | if (conduit_) |
|---|
| 144 | 144 | { |
|---|
| 145 | | conduit_.close(); |
|---|
| | 145 | conduit_.disconnect; |
|---|
| 146 | 146 | conduit_ = null; |
|---|
| 147 | 147 | } |
|---|
| r2304 |
r2497 |
|
| 121 | 121 | { |
|---|
| 122 | 122 | if (buffer) |
|---|
| 123 | | buffer.conduit.close; |
|---|
| | 123 | buffer.conduit.disconnect; |
|---|
| 124 | 124 | buffer = null; |
|---|
| 125 | 125 | } |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic