Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutexes and condition variables with names #380

Merged
merged 12 commits into from
Apr 3, 2019
Merged

Mutexes and condition variables with names #380

merged 12 commits into from
Apr 3, 2019

Conversation

jessymilare
Copy link
Contributor

Related to issue 372

Now make-mutex and make-condition accept an optional
argument name, which must be a symbol. When the mutex or
condition is printed, the name is also printed. The name
is immutable and can be accessed by mutex-name and
condition-name.

#372

Now `make-mutex` and `make-condition` accept an optional
argument name, which must be a symbol. When the mutex or
condition is printed, the name is also printed. The name
is immutable and can be accessed by mutex-name and
condition-name.
@dybvig
Copy link
Member

dybvig commented Jan 23, 2019

This looks good to me, thanks! Please add an entry to LOG. If you feel like updating the release notes and the user's guide as well, go ahead, or I'll make the changes after pulling the changes.

@jessymilare
Copy link
Contributor Author

Added entries to LOG and release notes and updated CSUG.

LOG Outdated
- add name fields for mutexes and condition variables, now `make-mutex` and
`make-condition` accept an optional argument `name`, which must be a
symbol. The name is printed every time the object is printed, which is
usefull for debugging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usefull => useful

\returns a new mutex object
\listlibraries
\endnoskipentryheader

\noindent
\var{name}, if supplied, must be a symbol which identifies the mutex. The
name is printed every time the mutex is printed, which is usefull for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useful

\noindent
\var{name}, if supplied, must be a symbol which identifies the condition
object. The name is printed every time the condition is printed, which is
usefull for debugging.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useful

The procedures \scheme{make-mutex} and \scheme{make-condition} now
accept an optional argument \scheme{name}, which must be a symbol
that identifies the object. The name is printed every time the mutex
or condition object is printed, which is usefull for debugging.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useful

s/prims.ss Outdated
m)]
[(name)
(unless (symbol? name)
($oops 'make-condition "~s is not a symbol" name))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be indented 1 more space

s/prims.ss Outdated
c)]
[(name)
(unless (symbol? name)
($oops 'make-condition "~s is not a symbol" name))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be indented 1 more space

@burgerrg
Copy link
Contributor

What do you think of allowing #f for the optional second argument of make-mutex and make-condition? This would make the definitions of the single-argument cases simpler and make it easier to write functions that take an optional name.

@dybvig
Copy link
Member

dybvig commented Jan 23, 2019

That's probably a good idea. I don't see how it simplifies the single-argument cases, however. In fact, they would need to explicitly allow #f as well as symbols, and the error messages would have to be adjusted.

@dybvig
Copy link
Member

dybvig commented Jan 23, 2019

@jessymilare, if you use set-who! rather than set! for make-mutex, mutex-name, make-condition, and condition-name, you can replace the quoted names with who in the error messages and just put each of the tests on one line to tighten up the code. I've been doing that with most of the things I've added recently.

@burgerrg
Copy link
Contributor

For the single argument cases, I meant that one could simply call the two-argument case with #f and wouldn't need to duplicate the body.

@dybvig
Copy link
Member

dybvig commented Jan 23, 2019

Ah, I guess you mean the zero-argument cases. Yes, but that would send the zero-argument case through an unnecessary check. Although if one the zero-argument case calls the one-argument case, the case-lambda form should be wrapped in a rec, e.g., (rec make-mutex <case-lambda form>) to make the call local, in which case cp0 would presumably inline the one-argument code into the zero-argument code and discard the check. Though I would probably instead just add a helper that both cases use to make clear the test isn't necessary in the zero-argument case.

@burgerrg
Copy link
Contributor

Thanks, I got my argument counts off by one! Yes, a helper without checks that is used by both front doors would be a good way to implement it.

@jessymilare
Copy link
Contributor Author

jessymilare commented Mar 24, 2019

Sorry for the polution in the commits. I use aggressive-indent-mode and I forgot to disable it before editing. If the code is OK, I can recreate the commits or create one single commit for all changes.

@burgerrg
Copy link
Contributor

The build system found an error while building the threaded versions of Chez Scheme: Details

Warning: undeclared variable assignment to $make-mutex at line 1485, char 1 of prims.ss

@jessymilare
Copy link
Contributor Author

The build system found an error while building the threaded versions of Chez Scheme: Details

Warning: undeclared variable assignment to $make-mutex at line 1485, char 1 of prims.ss

Fixed.

Copy link
Contributor

@burgerrg burgerrg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's almost ready!


The procedures \scheme{make-mutex} and \scheme{make-condition} now
accept an optional argument \scheme{name}, which must be a symbol
that identifies the object. The name is printed every time the mutex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or \scheme{#f} for no name

s/print.ss Outdated Show resolved Hide resolved
@burgerrg burgerrg merged commit 1397e17 into cisco:master Apr 3, 2019
@burgerrg
Copy link
Contributor

burgerrg commented Apr 3, 2019

Thank you for this pull request!

mflatt pushed a commit to racket/ChezScheme that referenced this pull request Mar 24, 2021
add name fields for mutexes and condition variables, now `make-mutex` and `make-condition` accept an optional argument `name`, which must be a symbol or #f.  The name, if not #f, is printed every time the object is printed, which is useful for debugging.
mflatt pushed a commit to mflatt/ChezScheme that referenced this pull request Oct 10, 2023
add name fields for mutexes and condition variables, now `make-mutex` and `make-condition` accept an optional argument `name`, which must be a symbol or #f.  The name, if not #f, is printed every time the object is printed, which is useful for debugging.

Original commit: 1397e17
mflatt pushed a commit to mflatt/ChezScheme that referenced this pull request Oct 10, 2023
add name fields for mutexes and condition variables, now `make-mutex` and `make-condition` accept an optional argument `name`, which must be a symbol or #f.  The name, if not #f, is printed every time the object is printed, which is useful for debugging.

Original commit: 1397e17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants