# Thread Safe ...

- Thread: https://externals.io/message/65368
- Original archive: https://news-web.php.net/php.internals/65368
- Started by Lester Caine on 2013-01-29T12:29:07+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #65368 — Lester Caine — 2013-01-29T12:29:07+00:00

URL: https://externals.io/message/65368#65368

Can someone please fill in a little information here. When we start looking at 
multiple threads doing for example database lookups in parallel with the main 
page generation. Does that involve 'thread safe' or is it done in a different 
way? Scheduling a data lookup on one thread while building the page the 
information is to be displayed on seems like a case for threading in the web 
server?

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #65370 — Ferenc Kovacs — 2013-01-29T13:00:48+00:00

URL: https://externals.io/message/65368#65370 · In reply to: #65368

> Can someone please fill in a little information here. When we start
> looking at multiple threads doing for example database lookups in parallel
> with the main page generation. Does that involve 'thread safe' or is it
> done in a different way? Scheduling a data lookup on one thread while
> building the page the information is to be displayed on seems like a case
> for threading in the web server?
>
>
we don't have threads in userspace in php, sou you can't do concurrent
execution of any function, but there are a couple of extensions providing
some way for concurrent/async execution.
for the scenario what you described one can use multiple db connections and
async queries
http://www.php.net/manual/en/mysqli.poll.php#refsect1-mysqli.poll-examplesfor
mysql
or just a single connection and doing some other work (like rendering the
layout) while waiting for the results.
if you are interested in a generic solution for concurrent execution you
could look into http://php.net/manual/en/book.pthreads.php

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

---

## #65410 — Lester Caine — 2013-01-29T15:32:52+00:00

URL: https://externals.io/message/65368#65410 · In reply to: #65370

Ferenc Kovacs wrote:
> 
>
> > […]
> we don't have threads in userspace in php, sou you can't do concurrent
> execution of any function, but there are a couple of extensions providing
> some way for concurrent/async execution.
> for the scenario what you described one can use multiple db connections and
> async queries
> http://www.php.net/manual/en/mysqli.poll.php#refsect1-mysqli.poll-examplesfor
> mysql
> or just a single connection and doing some other work (like rendering the
> layout) while waiting for the results.
> if you are interested in a generic solution for concurrent execution you
> could look into http://php.net/manual/en/book.pthreads.php

Thanks ...
That confirms what I thought. In order to add concurrent operations which to my 
mind are of more use than 'accessors' we do need ZTS mode enabled. This is I 
think a perfectly valid reason for wanting to maintain ZTS in the future?

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #65412 — Ferenc Kovacs — 2013-01-29T15:48:28+00:00

URL: https://externals.io/message/65368#65412 · In reply to: #65410

> Ferenc Kovacs wrote:
>
> > […]
>
> Thanks ...
> That confirms what I thought. In order to add concurrent operations which
> to my mind are of more use than 'accessors' we do need ZTS mode enabled.
> This is I think a perfectly valid reason for wanting to maintain ZTS in the
> future?
>
>
Yeah, and this was quickly accepted/agreed by Zeev as a reasonable usecase
when it was brought up in the other thread.


-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu
