Skip to content

Add lock_definitions.h#22283

Closed
khwilliamson wants to merge 1 commit intoPerl:bleadfrom
khwilliamson:lock_definitions.h
Closed

Add lock_definitions.h#22283
khwilliamson wants to merge 1 commit intoPerl:bleadfrom
khwilliamson:lock_definitions.h

Conversation

@khwilliamson
Copy link
Contributor

This file is intended to insulate C code from thread issues, when used as directed.

This file is intended to insulate C code from thread issues, when used
as directed.
if $entry->{locks} || $entry->{categories};
print $l <<~EOT;
#${dindent}define ${USE}_LOCK \\
#${dindent} error_${use}_not_suitable_for_multi-threaded_operation
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this generate:

#  error_foo_not suitable...

rather than

#  error foo_not suitable...

?
The first may produce an error, but it might not include the text of the symbol.

The second will produce the requested message, though it might be better to quote it, which will prevent macro replacement, allowing you to avoid the need for all_the_underscores.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It turns out that #error may not be the expansion of a macro, and that's why there are all the underscores. But the initial # generates a stray # in program message, so I removed it in #24098

# previous preprocessor lines. If there was no "#else" line, macros expanding
# to no-ops are automatically generated for the #else case.

__DATA__
Copy link
Contributor

Choose a reason for hiding this comment

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

Two issues, in general:

  1. This defines a huge number of names most of which will never be used, and have a potential to conflict with names from other libraries.

I think this should add a PERL_ prefix to each lock name.

  1. This defines separate symbols for each function in a closely related group of functions, for example dbm_* and any read locale function.

The separate macros imply the need to do each of those locks, even though in some cases it doesn't make sense, eg. if I do a dbm_delete(), I really don't want to release the lock until I do dbm_error().

I think macros should be defined for groups of such functions where it makes sense, eg. a single macro for the dbm_* functions, and just document the need for LC_*_LOCK for locale reading functions etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

I share @tonycoz's skepticism as to whether the addition of this header file is necessary or desirable.

Copy link
Contributor

Choose a reason for hiding this comment

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

@khwilliamson can you comment on the issues raised by @tonycoz in this ticket back in June?

(My sense is that there's not enough enthusiasm about the patch to warrant keeping this ticket open.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it could be useful, but it needs some work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can close it, but I will open it again when I finally get around to fixing it up

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like a plan. Closing ticket for the time being.

@jkeenan jkeenan added Closable? We might be able to close this ticket, but we need to check with the reporter and removed Closable? We might be able to close this ticket, but we need to check with the reporter labels Dec 14, 2024
@jkeenan jkeenan closed this Dec 19, 2024
@khwilliamson
Copy link
Contributor Author

#24098 replaces this p.r.

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