Commit Graph

4 Commits

Author SHA1 Message Date
Zoltan Somogyi
c02eb5163e Carve io.{call_system,environment}.m out of io.m.
library/io.call_system.m:
    Move the code in the "system access predicates" section of io.m
    to this new module.

library/io.environment.m:
    Move the predicates dealing with environment variables in io.m
    to this new module.

library/io.m:
    Delete the code moved to the new modules.

    Leave behind in io.m "forwarding predicates", predicates that do nothing
    except call the moved predicates in the new modules, to provide backward
    compatibility. But do mark the forwarding predicates as obsolete,
    to tell people to update their (at their leisure, since the obsoleteness
    warning can be turned off).

    Also leave behind in io.m the definitions of the types used
    by some parameters of some of the moved predicates.

library/MODULES_DOC:
    List the new modules among the documented modules.

library/library.m:
    List the new modules, including io.file.m (added in a previous change)
    among the documented standard library modules.

NEWS:
    Announce the changes.

browser/browse.m:
browser/interactive_query.m:
compiler/fact_table.m:
compiler/handle_options.m:
compiler/make.module_target.m:
compiler/mercury_compile_main.m:
compiler/module_cmds.m:
compiler/optimize.m:
compiler/options_file.m:
deep_profiler/conf.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_test.m:
library/io.file.m:
mdbcomp/trace_counts.m:
ssdb/ssdb.m:
tests/general/environment.m:
tests/hard_coded/closeable_channel_test.m:
tests/hard_coded/setenv.m:
tests/hard_coded/system_sort.m:
    Call the moved predicates directly in their new modules,
    not indirectly through io.m.
2022-03-08 09:38:27 +11:00
Peter Wang
5a233ef782 Change interface of closeable_channel.try_take.
library/thread.closeable_channel.m:
    Rename the `empty' result of closeable_channel.try_take to
    `would_block'.

tests/hard_coded/closeable_channel_test.exp:
tests/hard_coded/closeable_channel_test.m:
    Update test case.
2020-04-20 11:33:25 +10:00
Peter Wang
66094d3dbf Delete closeable_channel.is_closed.
This is a plausible sequence of events leading to a failure in the
hard_coded/closeable_channel_test.m test case:

     thread A                   thread B
     --------                   --------
     close(Chan)
                                channel.take(Chan)
                                   -> mvar.read(Head)
                                        -> semaphore.wait(Full)
     is_closed(Chan, IsClosed)
          -> mvar.try_read(Hole)
               -> semaphore.try_wait(Full)

Thread B tries to take the next item from the channel, during which time
it holds the Full semaphore of the mvar at the read end of the channel.

Thread A attempts to verify that the channel is really closed.
It tries to read from the mvar at the write end of the channel, which is
the same mvar as thread B is reading from (because the channel is empty).
Thread A cannot acquire the Full semaphore of the mvar as the semaphore
is being held by thread B, resulting in the call is_closed(Chan, IsClosed)
to return with IsClosed = no.

library/thread.closeable_channel.m:
    Delete the is_closed predicate. It was of questionable utility
    anyway.

tests/hard_coded/closeable_channel_test.m:
    Delete call to is_closed in test case.
2020-04-20 11:33:25 +10:00
Peter Wang
36e1e26b33 Add test for thread.closeable_channel.
tests/hard_coded/Mmakefile:
tests/hard_coded/closeable_channel_test.exp:
tests/hard_coded/closeable_channel_test.exp2:
tests/hard_coded/closeable_channel_test.m:
    Add new test.
2020-02-18 11:07:34 +11:00