use strict;
use warnings;
-our $VERSION = '1.05';
+our $VERSION = '1.06';
my $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
=head1 VERSION
-This document describes threads::shared version 1.05
+This document describes threads::shared version 1.06
=head1 SYNOPSIS
C<cond_signal> will normally generate a warning if you attempt to use it on an
unlocked variable. On the rare occasions where doing this may be sensible, you
-can skip the warning with:
+can suppress the warning with:
{ no warnings 'threads'; cond_signal($foo); }
L<http://www.cpanforum.com/dist/threads-shared>
Annotated POD for L<threads::shared>:
-L<http://annocpan.org/~JDHEDDEN/threads-shared-1.05/shared.pm>
+L<http://annocpan.org/~JDHEDDEN/threads-shared-1.06/shared.pm>
L<threads>, L<perlthrtut>
recursive_lock_release(pTHX_ recursive_lock_t *lock)
{
MUTEX_LOCK(&lock->mutex);
- if (lock->owner != aTHX) {
- MUTEX_UNLOCK(&lock->mutex);
- } else if (--lock->locks == 0) {
- lock->owner = NULL;
- COND_SIGNAL(&lock->cond);
+ if (lock->owner == aTHX) {
+ if (--lock->locks == 0) {
+ lock->owner = NULL;
+ COND_SIGNAL(&lock->cond);
+ }
}
MUTEX_UNLOCK(&lock->mutex);
}
}
-=for apidoc sharedsv_find
-
-Given a private side SV tries to find if the SV has a shared backend,
-by looking for the magic.
-
-=cut
-
+/* Given a private side SV tries to find if the SV has a shared backend,
+ * by looking for the magic.
+ */
SV *
Perl_sharedsv_find(pTHX_ SV *sv)
{
#endif
};
-=for apidoc sharedsv_unlock
-
-Recursively unlocks a shared sv.
-=cut
+/* Recursively unlocks a shared sv. */
void
Perl_sharedsv_unlock(pTHX_ SV *ssv)
recursive_lock_release(aTHX_ &ul->lock);
}
-=for apidoc sharedsv_lock
-
-Recursive locks on a sharedsv.
-Locks are dynamically scoped at the level of the first lock.
-
-=cut
+/* Recursive locks on a sharedsv.
+ * Locks are dynamically scoped at the level of the first lock.
+ */
void
Perl_sharedsv_lock(pTHX_ SV *ssv)
{
Perl_sharedsv_lock(aTHX_ ssv);
}
-=head1 Shared SV Functions
-
-=for apidoc sharedsv_init
-Saves a space for keeping SVs wider than an interpreter.
-
-=cut
+/* Saves a space for keeping SVs wider than an interpreter. */
void
Perl_sharedsv_init(pTHX)
}
if (ul->lock.owner != aTHX)
croak("You need a lock before you can cond_wait");
+
/* Stealing the members of the lock object worries me - NI-S */
MUTEX_LOCK(&ul->lock.mutex);
ul->lock.owner = NULL;
locks = ul->lock.locks;
ul->lock.locks = 0;
- /* Since we are releasing the lock here we need to tell other
- * people that is ok to go ahead and use it */
+ /* Since we are releasing the lock here, we need to tell other
+ * people that it is ok to go ahead and use it */
COND_SIGNAL(&ul->lock.cond);
COND_WAIT(user_condition, &ul->lock.mutex);
- while(ul->lock.owner != NULL) {
+ while (ul->lock.owner != NULL) {
/* OK -- must reacquire the lock */
COND_WAIT(&ul->lock.cond, &ul->lock.mutex);
}
ul->lock.owner = NULL;
locks = ul->lock.locks;
ul->lock.locks = 0;
- /* Since we are releasing the lock here we need to tell other
- * people that is ok to go ahead and use it */
+ /* Since we are releasing the lock here, we need to tell other
+ * people that it is ok to go ahead and use it */
COND_SIGNAL(&ul->lock.cond);
RETVAL = Perl_sharedsv_cond_timedwait(user_condition, &ul->lock.mutex, abs);
while (ul->lock.owner != NULL) {