On Thu, Apr 2, 2015 at 3:55 PM, Ryan Pallas <derokor...@gmail.com> wrote:

>
>
> On Thu, Apr 2, 2015 at 1:50 PM, Adam Harvey <ahar...@php.net> wrote:
>
>> On 2 April 2015 at 12:24, Dan Ackroyd <dan...@basereality.com> wrote:
>> > On 2 April 2015 at 16:01, Keyur Govande <keyurgova...@gmail.com> wrote:
>> >>
>> >>
>> >> To Rasmus's point, here's a PR for HHVM to provide a thread-safe
>> setlocale
>> >> implementation: https://github.com/facebook/hhvm/pull/4736/files
>> >>
>> >> It should be fairly easy to refactor the thread-safe-setlocale.(h/cpp)
>> files
>> >> for Zend.
>> >
>> > Ok, that' pretty awesome. So assumming that we incorporated that new
>> > thread safe version of locale, how would we expose it? Most people who
>> > are calling setlocale are unaware of it's side effects, and so should
>> > be using the new safe version by default.
>> >
>> > Some people who are calling setlocale will actually be using the
>> > cross-thread behaviour and so that still needs to work.
>> >
>> > setlocale is a variadic function, so it's not possible to hack in a
>> > flag parameter. As much as I dislike ini settings, it seems like
>> > adding one here would be sensible e.g. 'thread_safe_setlocale'
>> >
>> > * If it's enabled the setlocale function calls the new thread safe
>> > functionality.
>> >
>> > * If it's disabled the setlocale function calls the current non-TS C
>> > setlocale function.
>> >
>> >
>> > Does anyone have a better suggestion on exposing a thread safe version?
>>
>> What about just adding another function: setlocale_global(), or
>> similar? I don't want a new INI setting any more than you do.
>>
>> Adam
>>
>> --
>> PHP Internals - PHP Runtime Development Mailing List
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> I like the idea of an INI actually, but I would make it default to the
> current bahaviour and user education so those who need TS know to change it.
>

The thread-safe version sets the locale globally for each thread and any
code executing in that thread will be impacted. So the semantics are
similar to how setlocale(3) works in a process. The thread-safe code would
be wrapped in #ifdefs and only take effect in a right context.


>
> Ryan
>

Reply via email to