Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53979 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31080 invoked from network); 16 Jul 2011 10:14:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2011 10:14:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.177 as permitted sender) X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.177 mail-qy0-f177.google.com Received: from [209.85.216.177] ([209.85.216.177:48338] helo=mail-qy0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/50-28841-A94612E4 for ; Sat, 16 Jul 2011 06:14:51 -0400 Received: by qyk7 with SMTP id 7so1205042qyk.8 for ; Sat, 16 Jul 2011 03:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=1YWzDCCqLP+ARQQ64NievRvHHFhQa9MPEjK63DT0vvw=; b=RRWzTMGQcu2LlxRNu7tDUrdd5qiXmLIj2p5WYrZQZu8qcjjrvFAC2Gd+GQAqt9DY92 UiF6lZwKg40wGSAH9quWtbzbI6JD6uTfM3UpIqfVmQfel5GmnmLHJNtxqB9L8SZ4RAi8 d2V+3ujNM0KBfj3otowAySAsVFagcsjvUa6S8= Received: by 10.229.106.30 with SMTP id v30mr3292493qco.113.1310811288134; Sat, 16 Jul 2011 03:14:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.87.70 with HTTP; Sat, 16 Jul 2011 03:14:28 -0700 (PDT) Reply-To: RQuadling@GMail.com In-Reply-To: References: Date: Sat, 16 Jul 2011 11:14:28 +0100 Message-ID: To: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] weak references From: rquadling@gmail.com (Richard Quadling) On 14 July 2011 20:42, Ferenc Kovacs wrote: > To spare the "5.4 features vote" thread from the off-topic discussion, > we can continue here. > Hannes Landeholm brought this idea up, see > http://news.php.net/php.internals/53956 and > http://news.php.net/php.internals/53959 > I would suggest that Hannes create an rfc, and add some examples and > introduce the weak references in general and how this can be useful, > what problems do they solve (it was discussed in the bugreport, but it > wasn't clear as far as I can tell from the comments). Not being an expert here, so the questions may have obvious answers. How often does the gc cycle run during a script? Can preemptive cleanup actually cause more of a headache? In reading about weak references on http://en.wikipedia.org/wiki/Weak_reference, weak references look like a perfect use case for memory limited caches, but I wonder if there would be a way of synching a TTL to the weak referenced objects, so that they essentially automatically expire (or can be expired and expunged). A system controlled TTL for weak referenced objects. So, void SplWeakRef::__construct(object $ref, [int $ttl = -1]) $ttl = -1 would allow the object to be gc'd in the normal way, but any other value would be a hint to how long the object would be expected to last for. If gc happens frequently, then $ttl acts as a limiter and I think this could be very useful. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea