Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88457 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41047 invoked from network); 23 Sep 2015 21:16:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Sep 2015 21:16:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=zardozrocks@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=zardozrocks@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.177 as permitted sender) X-PHP-List-Original-Sender: zardozrocks@gmail.com X-Host-Fingerprint: 209.85.223.177 mail-io0-f177.google.com Received: from [209.85.223.177] ([209.85.223.177:34324] helo=mail-io0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/31-33598-AB613065 for ; Wed, 23 Sep 2015 17:16:43 -0400 Received: by iofb144 with SMTP id b144so56946974iof.1 for ; Wed, 23 Sep 2015 14:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=BtMR6yCB4omBicrX2q3KWZPZhHrpwZEh54MgOHWbZQE=; b=sYXTNWnLuvMRWw/x3ety/U+m9sF+8YC5zjp0NQJJz1ibJiKY5t5CXuLzOOsKYXEx2R Teysh8QiBMSr1cuXT4l0xA5SA71t6H7OeaidMJJeNwdUfazXODYtrBFqMiASmH0HIHJE v4lqp6VnGzZq+kb6gcI01YjhD+rHVlu2e6INp3ZT5MVBfzp7oZM2KJqjLafm7dnwzvod o5X8KT3DRKS+MgvtbRKIeBeOxSM3YeuilrR6MCT1qSt21M9Il5+UetzLq6E4aErdkm28 uUATkZBi0qYKg+Oallcu/XQ2iNaquApIoyHpbxAKahZtLAV67OcACS3iSzCuK9i0lhtU UFgQ== MIME-Version: 1.0 X-Received: by 10.107.8.89 with SMTP id 86mr38700369ioi.125.1443042999912; Wed, 23 Sep 2015 14:16:39 -0700 (PDT) Received: by 10.107.31.148 with HTTP; Wed, 23 Sep 2015 14:16:39 -0700 (PDT) In-Reply-To: <64233ECB-7422-4D7C-A8A5-E77FC98C09E2@gmail.com> References: <5601F58A.7000602@php.net> <64233ECB-7422-4D7C-A8A5-E77FC98C09E2@gmail.com> Date: Wed, 23 Sep 2015 14:16:39 -0700 Message-ID: To: internals Content-Type: multipart/alternative; boundary=001a113f3cd467d0ed052070a11f Subject: Re: [PHP-DEV] Data serialization of objects, want to iterate 'sealed' properties then dynamic ones From: zardozrocks@gmail.com (j adams) --001a113f3cd467d0ed052070a11f Content-Type: text/plain; charset=UTF-8 Not my intention to be combative, but what about http://php.net/pcntl_fork ? I've used that before in a robust distributed application that runs without any intervention for months. It's my understanding that PHP is thread safe, but not itself multithreaded. I believe there are some extensions which aren't thread safe. Also correct me if I'm wrong but Apache 2 should be run in it's prefork mode when using PHP. Also, any thoughts on my other questions? Sorry if I'm pressing my luck but they are far more pressing for me currently: 1) Is there not any way to first iterate through the default properties and then iterate through *only the dynamic properties* ? zend_object->properties appears to contain ALL properties if the object has a single dynamically-assigned property. If so, please advise? If not, it sounds like I must iterate through all properties and check each property's key to see if it's included among the default properties. Please confirm? 2) Will this code ALWAYS return the properties in the same sequence? E.g., if I am iterating through N objects of type MyClass, will each instance iterate the properties in the same order? 3) Will this code ALWAYS iterate over default properties (i.e., "sealed" properties, those explicitly defined by class definitinos) FIRST and then iterate any dynamically assigned properties? These questions are very important for my serialization algorithm. CODE: zobj = zend_objects_get_address(*val TSRMLS_CC); if (!zobj->properties) { php_printf("***No dynamic properties!\n"); } else { php_printf("***we got dynamic properties...sadly, this will also iterate through default properties too\n"); zend_hash_internal_pointer_reset_ex(zobj->properties, &pos); while (zend_hash_get_current_data_ex(zobj->properties, (void **) &value, &pos) == SUCCESS) { if (zend_hash_get_current_key_ex(zobj->properties, &key, &key_len, &num_index, 0, &pos) == HASH_KEY_IS_STRING) { if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) == SUCCESS) { zend_unmangle_property_name(key, key_len - 1, &class_name, &prop_name); php_printf("dynamic property is %s, key_len is %d\n", prop_name, key_len); } } zend_hash_move_forward_ex(zobj->properties, &pos); } } On Wed, Sep 23, 2015 at 1:33 PM, Rowan Collins wrote: > On 23 September 2015 20:48:33 BST, j adams wrote: > >> PHP uses an object store. > >Am I correct in understanding that the object store is a global data > >structure? Wouldn't this tend to discourage any attempts at > >multithreading/multiprocessing within one's PHP script--unless the > >object > >store is protected by a lock... > > PHP is inherently single-threaded as far as the user is concerned. There > are many things which would break if you changed that. > > The only way I know of to write multi-threaded PHP is using the pthreads > extension, which comes with some rather large caveats, and uses specific > objects to communicate between threads. > > Regards, > -- > Rowan Collins > [IMSoP] > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a113f3cd467d0ed052070a11f--