 |
Changeset 2505
- Timestamp:
- 08/26/07 15:18:55
(1 year ago)
- Author:
- kris
- Message:
Shuffled things around to resolve the flush() issue when closing a file. Tango has both a soft and hard flush, where the former is flush() and the latter is commit(). The change means that files are hard-committed when closed cleanly, which is expected. However, there may be a second invocation of the equivalent hard-commit within the OS itself when the file is actually closed. At this time we're asserting that won't be a performance hit.
The upshot is that you can force a hard flush of a FileConduit? (all the way to the disk) via a commit(). A flush() just ensures any internal buffering is emptied. FileConduit?.commit() checks itself for write access.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r2504 |
r2505 |
|
| 149 | 149 | ***********************************************************************/ |
|---|
| 150 | 150 | |
|---|
| 151 | | final void commit () {} |
|---|
| | 151 | void commit () {} |
|---|
| 152 | 152 | |
|---|
| 153 | 153 | /*********************************************************************** |
|---|
| … | … | |
| 156 | 156 | |
|---|
| 157 | 157 | Remarks: |
|---|
| 158 | | Close flushes & commits any filters, and disconnects the |
|---|
| 159 | | conduit. |
|---|
| | 158 | Close flushes & commits any filters before disconnecting |
|---|
| | 159 | the conduit |
|---|
| 160 | 160 | |
|---|
| 161 | 161 | ***********************************************************************/ |
|---|
| r2490 |
r2505 |
|
| 353 | 353 | /*************************************************************** |
|---|
| 354 | 354 | |
|---|
| 355 | | Intercept the default file-flushing implementation. |
|---|
| 356 | | We don't actually flush the console device per se, as |
|---|
| 357 | | the OS does not really like that. Flush any enclosing |
|---|
| 358 | | buffer instead. |
|---|
| 359 | | |
|---|
| 360 | | ***************************************************************/ |
|---|
| 361 | | |
|---|
| 362 | | override void flush () {} |
|---|
| 363 | | |
|---|
| 364 | | /*************************************************************** |
|---|
| 365 | | |
|---|
| 366 | 355 | Windows-specific code |
|---|
| 367 | 356 | |
|---|
| r2497 |
r2505 |
|
| 106 | 106 | error (); |
|---|
| 107 | 107 | handle = cast(HANDLE) null; |
|---|
| 108 | | } |
|---|
| 109 | | |
|---|
| 110 | | /*************************************************************** |
|---|
| 111 | | |
|---|
| 112 | | ***************************************************************/ |
|---|
| 113 | | |
|---|
| 114 | | override void flush () |
|---|
| 115 | | { |
|---|
| 116 | | if (! FlushFileBuffers (handle)) |
|---|
| 117 | | error (); |
|---|
| 118 | | return this; |
|---|
| 119 | 108 | } |
|---|
| 120 | 109 | |
|---|
| r2490 |
r2505 |
|
| 434 | 434 | /*************************************************************** |
|---|
| 435 | 435 | |
|---|
| | 436 | Ensures that data is flushed immediately to disk |
|---|
| | 437 | |
|---|
| | 438 | ***************************************************************/ |
|---|
| | 439 | |
|---|
| | 440 | override void commit () |
|---|
| | 441 | { |
|---|
| | 442 | if (style_.access & Access.Write) |
|---|
| | 443 | if (! FlushFileBuffers (handle)) |
|---|
| | 444 | error (); |
|---|
| | 445 | } |
|---|
| | 446 | |
|---|
| | 447 | /*************************************************************** |
|---|
| | 448 | |
|---|
| 436 | 449 | Set the file size to be that of the current seek |
|---|
| 437 | 450 | position. The file must be writable for this to |
|---|
| … | … | |
| 520 | 533 | if (handle is -1) |
|---|
| 521 | 534 | error (); |
|---|
| | 535 | } |
|---|
| | 536 | |
|---|
| | 537 | /*************************************************************** |
|---|
| | 538 | |
|---|
| | 539 | Ensures that data is flushed immediately to disk |
|---|
| | 540 | |
|---|
| | 541 | ***************************************************************/ |
|---|
| | 542 | |
|---|
| | 543 | override void commit () |
|---|
| | 544 | { |
|---|
| | 545 | // no Posix API for this :( |
|---|
| 522 | 546 | } |
|---|
| 523 | 547 | |
|---|
| r2504 |
r2505 |
|
| 105 | 105 | |
|---|
| 106 | 106 | Remarks: |
|---|
| 107 | | Close flushes & commits any filters, and disconnects the |
|---|
| 108 | | conduit. |
|---|
| | 107 | Close flushes & commits any filters before disconnecting |
|---|
| | 108 | the conduit |
|---|
| 109 | 109 | |
|---|
| 110 | 110 | ***********************************************************************/ |
|---|
| r2497 |
r2505 |
|
| 183 | 183 | final synchronized void flush () |
|---|
| 184 | 184 | { |
|---|
| | 185 | conduit.commit; |
|---|
| 185 | 186 | dirty = false; |
|---|
| 186 | | conduit.output.flush; |
|---|
| 187 | 187 | } |
|---|
| 188 | 188 | |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic