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

Changeset 2505

Show
Ignore:
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
  • trunk/tango/io/Conduit.d

    r2504 r2505  
    149149        ***********************************************************************/ 
    150150 
    151         final void commit () {} 
     151        void commit () {} 
    152152 
    153153        /*********************************************************************** 
     
    156156                 
    157157                Remarks: 
    158                 Close flushes & commits any filters, and disconnects the  
    159                 conduit. 
     158                Close flushes & commits any filters before disconnecting  
     159                the conduit 
    160160 
    161161        ***********************************************************************/ 
  • trunk/tango/io/Console.d

    r2490 r2505  
    353353                /*************************************************************** 
    354354 
    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  
    366355                        Windows-specific code 
    367356 
  • trunk/tango/io/DeviceConduit.d

    r2497 r2505  
    106106                                  error (); 
    107107                        handle = cast(HANDLE) null; 
    108                 } 
    109  
    110                 /*************************************************************** 
    111  
    112                 ***************************************************************/ 
    113  
    114                 override void flush () 
    115                 { 
    116                         if (! FlushFileBuffers (handle)) 
    117                               error (); 
    118                         return this; 
    119108                } 
    120109 
  • trunk/tango/io/FileConduit.d

    r2490 r2505  
    434434                /*************************************************************** 
    435435 
     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 
    436449                        Set the file size to be that of the current seek  
    437450                        position. The file must be writable for this to 
     
    520533                        if (handle is -1) 
    521534                            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 :( 
    522546                } 
    523547 
  • trunk/tango/io/model/IConduit.d

    r2504 r2505  
    105105                 
    106106                Remarks: 
    107                 Close flushes & commits any filters, and disconnects the  
    108                 conduit. 
     107                Close flushes & commits any filters before disconnecting  
     108                the conduit 
    109109 
    110110        ***********************************************************************/ 
  • trunk/tango/net/cluster/tina/QueueFile.d

    r2497 r2505  
    183183        final synchronized void flush () 
    184184        { 
     185                conduit.commit; 
    185186                dirty = false; 
    186                 conduit.output.flush; 
    187187        } 
    188188