Re: var watcher expense

[email protected] (Joshua N Pritikin)
Newsgroups perl.loop
Message-ID <[email protected]>
On Thu, Feb 03, 2000 at 07:42:23PM +0100, [email protected] wrote:
> > This restriction can be
> > relaxed in a future release if there is enough demand.
> 
> As you surely expected ;-), the first demand just arrived with this message.

OK.  It was easier than I expected:

==== //depot/D/Event/ChangeLog#121 - /cache/D/Event/ChangeLog ====
--- /tmp/tmp.20134.0	Thu Feb  3 16:14:08 2000
+++ /cache/D/Event/ChangeLog	Thu Feb  3 16:02:57 2000
@@ -1,5 +1,7 @@
 2000-02-03  Joshua Pritikin  <[email protected]>
 
+	* Allow var watchers to watch the same variable.
+
 	* Deprecated AUTOLOAD of Event->$type.  (Nick & Graham)
 
 	* Reworked priority documentation based on comments from
==== //depot/D/Event/c/var.c#21 - /cache/D/Event/c/var.c ====
--- /tmp/tmp.20134.1	Thu Feb  3 16:14:08 2000
+++ /cache/D/Event/c/var.c	Thu Feb  3 16:09:09 2000
@@ -69,8 +69,6 @@
 	return "cannot trace read-only variable";
     if (!SvUPGRADE(sv, SVt_PVMG))
 	return "SvUPGRADE failed";
-    if (mg_find(sv, 'U'))
-	return "var is already being traced";
 
     mgp = &SvMAGIC(sv);
     while ((mg = *mgp)) {
@@ -110,7 +108,7 @@
 
     mgp = &SvMAGIC(sv);
     while ((mg = *mgp)) {
-	if (mg->mg_obj == (SV*)ev)
+	if (mg->mg_type == 'U' && mg->mg_obj == (SV*)ev)
 	    break;
 	mgp = &mg->mg_moremagic;
     }
==== //depot/D/Event/t/unconfigured.t#3 - /cache/D/Event/t/unconfigured.t ====
--- /tmp/tmp.20134.2	Thu Feb  3 16:14:08 2000
+++ /cache/D/Event/t/unconfigured.t	Thu Feb  3 16:04:16 2000
@@ -1,7 +1,7 @@
 #!./perl -w
 
 use strict;
-use Test; plan test => 8;
+use Test; plan test => 7;
 use Event;
 use Event::type ':all';
 
@@ -27,7 +27,3 @@
 
 eval { Event->var(var => \$1) };
 ok $@, '/read\-only/';
-
-eval { Event->var(var => \$var) for 1..2 };
-ok $@, '/already being traced/';
-
==== //depot/D/Event/t/var.t#9 - /cache/D/Event/t/var.t ====
--- /tmp/tmp.20134.3	Thu Feb  3 16:14:08 2000
+++ /cache/D/Event/t/var.t	Thu Feb  3 16:12:31 2000
@@ -1,7 +1,7 @@
 # watch -*-perl-*-
 
 use strict;
-use Test; plan test => 5;
+use Test; plan test => 6;
 use Event qw(loop unloop);
 use Event::type qw(var idle);
 
@@ -19,6 +19,8 @@
 	   },
 	   desc => "var1"
 );
+
+Event->var(var => \$var1, cb => sub { ok $var1, 2 });
 
 Event->var(var => \$var2, cb =>
 	   sub {

-- 
"May the best description of competition prevail."
           via, but not speaking for Deutsche Bank
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.