Re: static constructor
| From: | Johannes Ott | Date: | Thu, 12 Mar 2015 15:10:28 +0000 |
| Subject: | Re: static constructor | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-84640@lists.php.net to get a copy of this message | ||
Am 12.03.2015 um 12:40 schrieb Niklas Keller:
>
> How would it behave for the second call? If the first initialize fails due
> to some exception, should that static constructor be executed again?
>
I think there a two different solutions and I do not know which one I
prefer at the moment:
1. No second call can raise an fatal.
2. Yes should be executed again
As an internal implementation, we can do a flag which is at creation
time of class false and set after sucessful run of the static
constructor to true.
Do avoid deadlocks in loops like in the example maybe we can implement a
combination of both solutions. We can implement the flag not as a
boolean but as an integer counter. Raising a FATAL after X retries.
Regards,
--
DerOetzi