Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47789 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61885 invoked from network); 5 Apr 2010 15:58:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Apr 2010 15:58:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=mozo@mozo.jp; spf=permerror; sender-id=permerror Authentication-Results: pb1.pair.com header.from=mozo@mozo.jp; sender-id=permerror Received-SPF: error (pb1.pair.com: domain mozo.jp from 209.85.221.191 cause and error) X-PHP-List-Original-Sender: mozo@mozo.jp X-Host-Fingerprint: 209.85.221.191 mail-qy0-f191.google.com Received: from [209.85.221.191] ([209.85.221.191:36372] helo=mail-qy0-f191.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6F/10-60700-D880ABB4 for ; Mon, 05 Apr 2010 11:58:06 -0400 Received: by qyk29 with SMTP id 29so4369463qyk.2 for ; Mon, 05 Apr 2010 08:58:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.99.196 with HTTP; Mon, 5 Apr 2010 08:57:38 -0700 (PDT) In-Reply-To: <1288EF47-3DAE-4162-B9A6-FD21ACAEF8BB@gmail.com> References: <1941231697.20100401163215@gmail.com> <1288EF47-3DAE-4162-B9A6-FD21ACAEF8BB@gmail.com> Date: Tue, 6 Apr 2010 00:57:38 +0900 Received: by 10.229.188.212 with SMTP id db20mr8296007qcb.5.1270483079130; Mon, 05 Apr 2010 08:57:59 -0700 (PDT) Message-ID: To: Alexey Zakhlestin Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] php and multithreading (additional arguments) From: mozo@mozo.jp (Moriyoshi Koizumi) On Mon, Apr 5, 2010 at 7:17 PM, Alexey Zakhlestin wrot= e: > > On 05.04.2010, at 13:46, Moriyoshi Koizumi wrote: > >> I used to play with TSRM days ago and successfully implemented >> userland threading support using GNU Pth. =A0It's just a proof of >> concept and I did it for fun. > > So these are share-nothing worker-threads, which can send results to "mas= ter-thread" using messages. right? > I am perfectly fine with such approach A new thread can be created within a sub-thread as well. In addition, messages can be interchanged between any pair of threads. While it is based on shared-nothing approach, some kinds of resources are shared across threads besides classes and functions that would have already been defined before the thread creation. > > some stylistic moments: > * I would use closures instead of callback-functions I was trying hard to make closures work with the extension, but it wouldn't end up with a success. I guess I can fix it somehow. > * Is extra language construct really needed? function-call would work jus= t fine I don't quite think so. It was just an experiment, and each extra syntactic sugar would get converted to a corresponding single function call (either thread_message_queue_post() or thread_message_queue_poll() .) > Is overhead of starting new thread large? The cost is almost the same as when spawning a new runtime instance on a threaded web server with TSRM enabled. If you'd pass a large data to the subthread, then the overhead should go large because of the deep copy. Moriyoshi