PreviousUpNext

13.4.186  winix_file_io_mutex

The standard library winix_file_io_mutex package exports a mutex ("mutual exclusion") for use by posix-threaded code. The standard.lib cross-platform "winix" file I/O logic is not currently threadsafe, so parallel code should protect calls to winix functions (such as those in the file package) via logic like:

    stipulate
        package hth =  hostthread;
        package mtx =  winix_file_io_mutex;
    herein
    
        package foo {
              #
              # Define a hostthread-safe function to output lines:
              #
              fun pline  line_fn
                  =
                  hth::with_mutex_do  mtx::mutex  {.
                      #
                      line =  line_fn ()  +  "\n";
                      #
                      file::write (file::stdout, line );
                 };
    
            < omitted code >

                  pline . { sprintf "Fiddle %d  faddle %d" foo bar;  };
                
            < omitted code >
          };
    end;

The winix_file_io_mutex package source code is in src/lib/std/src/io/winix-file-io-mutex.pkg.

See also: file.

See also: hostthread.

The above information is manually maintained and may contain errors.

api {
    mutex : hostthread::Mutex;};

Comments and suggestions to: bugs@mythryl.org

PreviousUpNext