Skip to content

Commit 34bf176

Browse files
author
Jerry D. Hedden
committed
Merge pull request #1 from Dual-Life/develop
1.51 Sync with blead
2 parents 3d1d3ff + 1267107 commit 34bf176

File tree

9 files changed

+70
-51
lines changed

9 files changed

+70
-51
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ nytprof.out
1818
*.o
1919
*.bs
2020
/_eumm/
21+
22+
/ARCHIVE/
23+
/stuff/
24+
/Notes.txt

Changes

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
Revision history for Perl extension threads::shared.
22

33
-
4+
-
5+
6+
1.51 Fri Apr 22 19:05:18 2016
7+
- Documented that 'bless' does not propagate to nested shared items.
8+
9+
1.48 Sat Jun 13 12:00:00 2015
410
- Fix for when freeing elements with $#shared = N to trigger shared object destruction
511

12+
1.46 Tue Feb 4 21:48:51 2014
13+
- Sync from blead that fixes a thread context issue
14+
15+
1.45 Wed Nov 13 15:27:09 2013
16+
- Sync from blead
17+
618
1.43 Fri Jan 11 15:49:59 2013
719
- Timeout fix for t/stress.t (Nicholas Clark)
820

@@ -28,9 +40,6 @@ Revision history for Perl extension threads::shared.
2840
1.36 Fri Dec 24 16:50:11 2010
2941
- POD update
3042

31-
1.35 Mon Dec 20 15:09:01 2010
32-
- Sync from blead (not released on CPAN)
33-
3443
1.34 Fri Oct 8 16:48:25 2010
3544
- Veto signal dispatch hook (commit 65c7421c80585e0d12a20773935dc01f4ffa3e42)
3645

MANIFEST

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,3 @@ t/wait.t
3030
t/waithires.t
3131
t/test.pl
3232
examples/class.pl
33-
META.yml Module YAML meta-data (added by MakeMaker)
34-
META.json Module JSON meta-data (added by MakeMaker)

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
threads::shared version 1.48
1+
threads::shared version 1.51
22
============================
33

44
This module needs Perl 5.8.0 or later compiled with USEITHREADS.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# threads-shared
22
The 'threads-shared' module for Perl.
3+
4+
This module is dual-lived in both the core Perl distribution and on CPAN.
5+

hints/linux.pl

100755100644
File mode changed.

lib/threads/shared.pm

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use warnings;
77

88
use Scalar::Util qw(reftype refaddr blessed);
99

10-
our $VERSION = '1.48'; # Please update the pod, too.
10+
our $VERSION = '1.51'; # Please update the pod, too.
1111
my $XS_VERSION = $VERSION;
1212
$VERSION = eval $VERSION;
1313

@@ -195,7 +195,7 @@ threads::shared - Perl extension for sharing data structures between threads
195195
196196
=head1 VERSION
197197
198-
This document describes threads::shared version 1.48
198+
This document describes threads::shared version 1.51
199199
200200
=head1 SYNOPSIS
201201
@@ -558,6 +558,17 @@ they contain will be lost.
558558
Therefore, populate such variables B<after> declaring them as shared. (Scalar
559559
and scalar refs are not affected by this problem.)
560560
561+
Blessing a shared item after it has been nested in another shared item does
562+
not propagate the blessing to the shared reference:
563+
564+
my $foo = &share({});
565+
my $bar = &share({});
566+
$bar->{foo} = $foo;
567+
bless($foo, 'baz'); # $foo is now of class 'baz',
568+
# but $bar->{foo} is unblessed.
569+
570+
Therefore, you should bless objects before sharing them.
571+
561572
It is often not wise to share an object unless the class itself has been
562573
written to support sharing. For example, an object's destructor may get
563574
called multiple times, once for each thread's scope exit. Another danger is

shared.xs

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -179,22 +179,22 @@ typedef struct {
179179

180180
static recursive_lock_t PL_sharedsv_lock; /* Mutex protecting the shared sv space */
181181

182-
void
182+
static void
183183
recursive_lock_init(pTHX_ recursive_lock_t *lock)
184184
{
185185
Zero(lock,1,recursive_lock_t);
186186
MUTEX_INIT(&lock->mutex);
187187
COND_INIT(&lock->cond);
188188
}
189189

190-
void
190+
static void
191191
recursive_lock_destroy(pTHX_ recursive_lock_t *lock)
192192
{
193193
MUTEX_DESTROY(&lock->mutex);
194194
COND_DESTROY(&lock->cond);
195195
}
196196

197-
void
197+
static void
198198
recursive_lock_release(pTHX_ recursive_lock_t *lock)
199199
{
200200
MUTEX_LOCK(&lock->mutex);
@@ -207,7 +207,7 @@ recursive_lock_release(pTHX_ recursive_lock_t *lock)
207207
MUTEX_UNLOCK(&lock->mutex);
208208
}
209209

210-
void
210+
static void
211211
recursive_lock_acquire(pTHX_ recursive_lock_t *lock, const char *file, int line)
212212
{
213213
PERL_UNUSED_ARG(file);
@@ -276,7 +276,7 @@ typedef struct {
276276
we free the memory for the above.
277277
*/
278278

279-
int
279+
static int
280280
sharedsv_userlock_free(pTHX_ SV *sv, MAGIC *mg)
281281
{
282282
user_lock *ul = (user_lock *) mg->mg_ptr;
@@ -393,7 +393,7 @@ S_get_userlock(pTHX_ SV* ssv, bool create)
393393
/* Given a private side SV tries to find if the SV has a shared backend,
394394
* by looking for the magic.
395395
*/
396-
SV *
396+
static SV *
397397
Perl_sharedsv_find(pTHX_ SV *sv)
398398
{
399399
MAGIC *mg;
@@ -429,7 +429,7 @@ Perl_sharedsv_find(pTHX_ SV *sv)
429429
* magics at it.
430430
* Assumes lock is held.
431431
*/
432-
void
432+
static void
433433
Perl_sharedsv_associate(pTHX_ SV *sv, SV *ssv)
434434
{
435435
MAGIC *mg = 0;
@@ -548,7 +548,7 @@ S_sharedsv_dec(pTHX_ SV* ssv)
548548

549549
/* Implements Perl-level share() and :shared */
550550

551-
void
551+
static void
552552
Perl_sharedsv_share(pTHX_ SV *sv)
553553
{
554554
switch(SvTYPE(sv)) {
@@ -609,7 +609,7 @@ S_abs_2_rel_milli(double abs)
609609

610610
/* Do OS-specific condition timed wait */
611611

612-
bool
612+
static bool
613613
Perl_sharedsv_cond_timedwait(perl_cond *cond, perl_mutex *mut, double abs)
614614
{
615615
#if defined(NETWARE) || defined(I_MACH_CTHREADS)
@@ -730,7 +730,7 @@ S_get_RV(pTHX_ SV *sv, SV *sobj) {
730730

731731
/* Get magic for PERL_MAGIC_shared_scalar(n) */
732732

733-
int
733+
static int
734734
sharedsv_scalar_mg_get(pTHX_ SV *sv, MAGIC *mg)
735735
{
736736
SV *ssv = (SV *) mg->mg_ptr;
@@ -750,7 +750,7 @@ sharedsv_scalar_mg_get(pTHX_ SV *sv, MAGIC *mg)
750750
* Used by various mg_set()-type functions.
751751
* Assumes lock is held.
752752
*/
753-
void
753+
static void
754754
sharedsv_scalar_store(pTHX_ SV *sv, SV *ssv)
755755
{
756756
dTHXc;
@@ -809,7 +809,7 @@ sharedsv_scalar_store(pTHX_ SV *sv, SV *ssv)
809809

810810
/* Set magic for PERL_MAGIC_shared_scalar(n) */
811811

812-
int
812+
static int
813813
sharedsv_scalar_mg_set(pTHX_ SV *sv, MAGIC *mg)
814814
{
815815
SV *ssv = (SV*)(mg->mg_ptr);
@@ -828,7 +828,7 @@ sharedsv_scalar_mg_set(pTHX_ SV *sv, MAGIC *mg)
828828

829829
/* Free magic for PERL_MAGIC_shared_scalar(n) */
830830

831-
int
831+
static int
832832
sharedsv_scalar_mg_free(pTHX_ SV *sv, MAGIC *mg)
833833
{
834834
PERL_UNUSED_ARG(sv);
@@ -847,7 +847,7 @@ sharedsv_scalar_mg_free(pTHX_ SV *sv, MAGIC *mg)
847847
/*
848848
* Called during cloning of PERL_MAGIC_shared_scalar(n) magic in new thread
849849
*/
850-
int
850+
static int
851851
sharedsv_scalar_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *param)
852852
{
853853
PERL_UNUSED_ARG(param);
@@ -859,7 +859,7 @@ sharedsv_scalar_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *param)
859859
/*
860860
* Called during local $shared
861861
*/
862-
int
862+
static int
863863
sharedsv_scalar_mg_local(pTHX_ SV* nsv, MAGIC *mg)
864864
{
865865
MAGIC *nmg;
@@ -895,7 +895,7 @@ const MGVTBL sharedsv_scalar_vtbl = {
895895

896896
/* Get magic for PERL_MAGIC_tiedelem(p) */
897897

898-
int
898+
static int
899899
sharedsv_elem_mg_FETCH(pTHX_ SV *sv, MAGIC *mg)
900900
{
901901
dTHXc;
@@ -945,7 +945,7 @@ sharedsv_elem_mg_FETCH(pTHX_ SV *sv, MAGIC *mg)
945945

946946
/* Set magic for PERL_MAGIC_tiedelem(p) */
947947

948-
int
948+
static int
949949
sharedsv_elem_mg_STORE(pTHX_ SV *sv, MAGIC *mg)
950950
{
951951
dTHXc;
@@ -988,7 +988,7 @@ sharedsv_elem_mg_STORE(pTHX_ SV *sv, MAGIC *mg)
988988

989989
/* Clear magic for PERL_MAGIC_tiedelem(p) */
990990

991-
int
991+
static int
992992
sharedsv_elem_mg_DELETE(pTHX_ SV *sv, MAGIC *mg)
993993
{
994994
dTHXc;
@@ -1030,7 +1030,7 @@ sharedsv_elem_mg_DELETE(pTHX_ SV *sv, MAGIC *mg)
10301030
/* Called during cloning of PERL_MAGIC_tiedelem(p) magic in new
10311031
* thread */
10321032

1033-
int
1033+
static int
10341034
sharedsv_elem_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *param)
10351035
{
10361036
PERL_UNUSED_ARG(param);
@@ -1056,7 +1056,7 @@ const MGVTBL sharedsv_elem_vtbl = {
10561056

10571057
/* Len magic for PERL_MAGIC_tied(P) */
10581058

1059-
U32
1059+
static U32
10601060
sharedsv_array_mg_FETCHSIZE(pTHX_ SV *sv, MAGIC *mg)
10611061
{
10621062
dTHXc;
@@ -1076,7 +1076,7 @@ sharedsv_array_mg_FETCHSIZE(pTHX_ SV *sv, MAGIC *mg)
10761076

10771077
/* Clear magic for PERL_MAGIC_tied(P) */
10781078

1079-
int
1079+
static int
10801080
sharedsv_array_mg_CLEAR(pTHX_ SV *sv, MAGIC *mg)
10811081
{
10821082
dTHXc;
@@ -1110,7 +1110,7 @@ sharedsv_array_mg_CLEAR(pTHX_ SV *sv, MAGIC *mg)
11101110

11111111
/* Free magic for PERL_MAGIC_tied(P) */
11121112

1113-
int
1113+
static int
11141114
sharedsv_array_mg_free(pTHX_ SV *sv, MAGIC *mg)
11151115
{
11161116
PERL_UNUSED_ARG(sv);
@@ -1124,11 +1124,11 @@ sharedsv_array_mg_free(pTHX_ SV *sv, MAGIC *mg)
11241124
* the array -
11251125
*/
11261126
#if PERL_VERSION >= 11
1127-
int
1127+
static int
11281128
sharedsv_array_mg_copy(pTHX_ SV *sv, MAGIC* mg,
11291129
SV *nsv, const char *name, I32 namlen)
11301130
#else
1131-
int
1131+
static int
11321132
sharedsv_array_mg_copy(pTHX_ SV *sv, MAGIC* mg,
11331133
SV *nsv, const char *name, int namlen)
11341134
#endif
@@ -1143,7 +1143,7 @@ sharedsv_array_mg_copy(pTHX_ SV *sv, MAGIC* mg,
11431143

11441144
/* Called during cloning of PERL_MAGIC_tied(P) magic in new thread */
11451145

1146-
int
1146+
static int
11471147
sharedsv_array_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *param)
11481148
{
11491149
PERL_UNUSED_ARG(param);
@@ -1166,21 +1166,10 @@ const MGVTBL sharedsv_array_vtbl = {
11661166
};
11671167

11681168

1169-
/* Recursively unlocks a shared sv. */
1170-
1171-
void
1172-
Perl_sharedsv_unlock(pTHX_ SV *ssv)
1173-
{
1174-
user_lock *ul = S_get_userlock(aTHX_ ssv, 0);
1175-
assert(ul);
1176-
recursive_lock_release(aTHX_ &ul->lock);
1177-
}
1178-
1179-
11801169
/* Recursive locks on a sharedsv.
11811170
* Locks are dynamically scoped at the level of the first lock.
11821171
*/
1183-
void
1172+
static void
11841173
Perl_sharedsv_lock(pTHX_ SV *ssv)
11851174
{
11861175
user_lock *ul;
@@ -1192,7 +1181,7 @@ Perl_sharedsv_lock(pTHX_ SV *ssv)
11921181

11931182
/* Handles calls from lock() builtin via PL_lockhook */
11941183

1195-
void
1184+
static void
11961185
Perl_sharedsv_locksv(pTHX_ SV *sv)
11971186
{
11981187
SV *ssv;
@@ -1211,7 +1200,7 @@ Perl_sharedsv_locksv(pTHX_ SV *sv)
12111200
* or if destroying last proxy on a shared object
12121201
*/
12131202
#ifdef PL_destroyhook
1214-
bool
1203+
static bool
12151204
Perl_shared_object_destroy(pTHX_ SV *sv)
12161205
{
12171206
SV *ssv;
@@ -1243,7 +1232,7 @@ S_shared_signal_hook(pTHX) {
12431232

12441233
/* Saves a space for keeping SVs wider than an interpreter. */
12451234

1246-
void
1235+
static void
12471236
Perl_sharedsv_init(pTHX)
12481237
{
12491238
dTHXc;

t/test.pl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,17 +445,22 @@ ($$$@)
445445
# We just accept like(..., qr/.../), not like(..., '...'), and
446446
# definitely not like(..., '/.../') like
447447
# Test::Builder::maybe_regex() does.
448-
unless (ref($expected) && ref($expected) =~ /Regexp/) {
448+
unless (re::is_regexp($expected)) {
449449
die "PANIC: The value '$expected' isn't a regexp. The like() function needs a qr// pattern, not a string";
450450
}
451451

452452
my $pass;
453453
$pass = $_[1] =~ /$expected/ if !$flip;
454454
$pass = $_[1] !~ /$expected/ if $flip;
455+
my $display_got = $_[1];
456+
$display_got = display($display_got);
457+
my $display_expected = $expected;
458+
$display_expected = display($display_expected);
455459
unless ($pass) {
456-
unshift(@mess, "# got '$_[1]'\n",
460+
unshift(@mess, "# got '$display_got'\n",
457461
$flip
458-
? "# expected !~ /$expected/\n" : "# expected /$expected/\n");
462+
? "# expected !~ /$display_expected/\n"
463+
: "# expected /$display_expected/\n");
459464
}
460465
local $Level = $Level + 1;
461466
_ok($pass, _where(), $name, @mess);

0 commit comments

Comments
 (0)