Skip to content

Commit

Permalink
Move locking logic to Metamodel::Naming role
Browse files Browse the repository at this point in the history
It was the only way to have "protect" functionality on all fooHOW
classes, including ones in the ecosystem, most notably Inline::Perl5.
  • Loading branch information
lizmat committed Mar 20, 2024
1 parent 20376f0 commit 98ca8eb
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 21 deletions.
1 change: 0 additions & 1 deletion src/Perl6/Metamodel/ClassHOW.nqp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class Perl6::Metamodel::ClassHOW
does Perl6::Metamodel::Locking
does Perl6::Metamodel::Naming
does Perl6::Metamodel::BUILDALL
does Perl6::Metamodel::Documenting
Expand Down
1 change: 0 additions & 1 deletion src/Perl6/Metamodel/ConcreteRoleHOW.nqp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class Perl6::Metamodel::ConcreteRoleHOW
does Perl6::Metamodel::Locking
does Perl6::Metamodel::Naming
does Perl6::Metamodel::BUILDALL
does Perl6::Metamodel::Composing
Expand Down
1 change: 0 additions & 1 deletion src/Perl6/Metamodel/CurriedRoleHOW.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# as both a way to curry on your way to a full specialization, but also
# as a way to do type-checking or punning.
class Perl6::Metamodel::CurriedRoleHOW
does Perl6::Metamodel::Locking
does Perl6::Metamodel::Naming
does Perl6::Metamodel::BUILDALL
does Perl6::Metamodel::RolePunning
Expand Down
1 change: 0 additions & 1 deletion src/Perl6/Metamodel/EnumHOW.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# created at composition time. It supports having roles composed in,
# one or two of which presumably provide the core enum-ish methods.
class Perl6::Metamodel::EnumHOW
does Perl6::Metamodel::Locking
does Perl6::Metamodel::Naming
does Perl6::Metamodel::BUILDALL
does Perl6::Metamodel::Documenting
Expand Down
12 changes: 0 additions & 12 deletions src/Perl6/Metamodel/Locking.nqp

This file was deleted.

12 changes: 12 additions & 0 deletions src/Perl6/Metamodel/Naming.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ role Perl6::Metamodel::Naming {
method set_shortname($XXX, $shortname) {
$!shortname := $shortname;
}

#-------------------------------------------------------------------------------
# Note that this locking logic has nothing to do with naming. But it was
# the only way to have "protect" functionality on all fooHOW classes,
# including ones in the ecosystem, most notably Inline::Perl5.

has $!locking;

method TWEAK(*%_) { $!locking := NQPLock.new }

method protect(&code) { $!locking.protect(&code) }
#-------------------------------------------------------------------------------
}

# vim: expandtab sw=4
1 change: 0 additions & 1 deletion src/Perl6/Metamodel/NativeHOW.nqp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class Perl6::Metamodel::NativeHOW
does Perl6::Metamodel::Locking
does Perl6::Metamodel::Naming
does Perl6::Metamodel::BUILDALL
does Perl6::Metamodel::Documenting
Expand Down
1 change: 0 additions & 1 deletion src/Perl6/Metamodel/NativeRefHOW.nqp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#- Metamodel::NativeRefHOW -----------------------------------------------------
class Perl6::Metamodel::NativeRefHOW
does Perl6::Metamodel::Locking
does Perl6::Metamodel::Naming
does Perl6::Metamodel::BUILDALL
does Perl6::Metamodel::Documenting
Expand Down
1 change: 0 additions & 1 deletion src/Perl6/Metamodel/ParametricRoleGroupHOW.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# list by multi-dispatching over the set of candidates to pick
# a particular candidate.
class Perl6::Metamodel::ParametricRoleGroupHOW
does Perl6::Metamodel::Locking
does Perl6::Metamodel::Naming
does Perl6::Metamodel::BUILDALL
does Perl6::Metamodel::Stashing
Expand Down
1 change: 0 additions & 1 deletion src/Perl6/Metamodel/ParametricRoleHOW.nqp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
my $concrete := Perl6::Metamodel::ConcreteRoleHOW;
my $currier := Perl6::Metamodel::CurriedRoleHOW;
class Perl6::Metamodel::ParametricRoleHOW
does Perl6::Metamodel::Locking
does Perl6::Metamodel::Naming
does Perl6::Metamodel::BUILDALL
does Perl6::Metamodel::Documenting
Expand Down
4 changes: 4 additions & 0 deletions src/Perl6/Metamodel/Stashing.nqp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#- Metamodel::Stashing ---------------------------------------------------------
# Provides the logic for stashes with a metaclass object

role Perl6::Metamodel::Stashing {

method add_stash($type_obj) {
my $stash_type := Perl6::Metamodel::Configuration.stash_type;
unless nqp::isnull($stash_type) {
Expand Down
1 change: 0 additions & 1 deletion tools/templates/common_metamodel_sources
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
src/Perl6/Metamodel/Configuration.nqp
src/Perl6/Metamodel/Archetypes.nqp
src/Perl6/Metamodel/Locking.nqp
src/Perl6/Metamodel/Naming.nqp
src/Perl6/Metamodel/Documenting.nqp
src/Perl6/Metamodel/Explaining.nqp
Expand Down

0 comments on commit 98ca8eb

Please sign in to comment.