Hi,

as i've mentioned, that's up to implementation, for more infos please pay
attention to

http://en.wikipedia.org/wiki/Coroutine#Implementations_for_C

Well, the libtask mentioned there isn't thread safe (but could be made).

Especially have earned some attention

http://msdn.microsoft.com/en-us/library/windows/desktop/ms684847(v=vs.85).aspx#fiber_functions

and

https://github.com/stevedekorte/coroutine

which is portable.

Regards

Anatoliy

Am Mo, 11.06.2012, 23:12 schrieb Tom Boutell:
> Can you really use setjmp and longjmp in that way safely? I thought it
> was only safe to longjmp "back," not "forward" - you can use them to
> fake exception support but that's it because you'll smash the stack
> otherwise. Something like that...
>
> OK, I'm thinking of this:
>
> "Similarly, C99 does not require that longjmp preserve the current
> stack frame. This means that jumping into a function which was exited
> via a call to longjmp is undefined.[6] However, most implementations
> of longjmp leave the stack frame intact, allowing setjmp and longjmp
> to be used to jump back-and-forth between two or more functions?a
> feature exploited for multitasking."
>
> It does not sound like something that can be done in portable C.
>
> On Mon, Jun 11, 2012 at 4:13 PM, Anatoliy Belsky <a...@php.net> wrote:
>> Hi,
>>
>> it'd be really cool if the implementation would do the "real" context
>> switch in c, which would be the true basis for spl_coroutine. The
>> current
>> implementation seems not to do that.
>>
>> Context switch in c would be comparable with threads. In fact coroutines
>> would be a comensation for lacking threads functionality in php, as they
>> are already implemented on most popular platforms. However, it would
>> require some platform specific libs (fibers on windows, setjmp and
>> longjmp
>> on unix(like)).
>>
>> Coroutines in c are per se thread safe, so implementing them once would
>> not hurt both ts and nts. Additionally, in some cases coroutines can
>> even
>> have advantages over the "usual" preemptive threads.
>>
>> Regards
>>
>> Anatoliy
>>
>> Am Mi, 6.06.2012, 04:42 schrieb Laruence:
>>> On Wed, Jun 6, 2012 at 10:27 AM, Laruence <larue...@php.net> wrote:
>>>> On Wed, Jun 6, 2012 at 10:15 AM, Laruence <larue...@php.net> wrote:
>>>>> Hi Nikita:
>>>>>
>>>>>    the most important part to me is how did you implemented `yield`
>>>>> keyword,   is there a whole patch file I can look into?
>>>> Nervermind,  I will check the branch out later
>>>>
>>>> thanks
>>>
>>> After a quick look,  I think the main idea should goes to two parts:
>>>
>>> 1. implement yield (Zend)
>>> 2. implement spl_generators but not generator class (Spl)
>>>
>>> then we can implement spl_coroutine later base on this.  what do you
>>> think?
>>>
>>> thanks
>>>>>
>>>>>    what will happen if you use a `yield` in a normal function?
>>>>>
>>>>>    actually,  I tried to implemented coroutine, but since I could not
>>>>> find a way to make zend_execute interruptable, then I didn't make it.
>>>>>
>>>>>    so, I am really interesting of this tech-specific :)
>>>>>
>>>>> thanks
>>>>>
>>>>> On Wed, Jun 6, 2012 at 1:35 AM, Nikita Popov
>>>>> <nikita....@googlemail.com> wrote:
>>>>>> Hi internals!
>>>>>>
>>>>>> In the last few days I've created a proof of concept implementation
>>>>>> for generators in PHP. It's not yet complete, but the basic
>>>>>> functionality is there:
>>>>>> https://github.com/nikic/php-src/tree/addGeneratorsSupport
>>>>>>
>>>>>> The implementation is outlined in the RFC-stub here:
>>>>>> https://wiki.php.net/rfc/generators
>>>>>>
>>>>>> Before going any further I'd like to get some comments about what
>>>>>> you
>>>>>> think of adding generator support to PHP.
>>>>>>
>>>>>> If you don't know what generators are you should have a look at the
>>>>>> "Introduction" section in the above RFC or in the Python
>>>>>> documentation
>>>>>> at http://wiki.python.org/moin/Generators.
>>>>>>
>>>>>> Nikita
>>>>>>
>>>>>> --
>>>>>> PHP Internals - PHP Runtime Development Mailing List
>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Laruence  Xinchen Hui
>>>>> http://www.laruence.com/
>>>>
>>>>
>>>>
>>>> --
>>>> Laruence  Xinchen Hui
>>>> http://www.laruence.com/
>>>
>>>
>>>
>>> --
>>> Laruence  Xinchen Hui
>>> http://www.laruence.com/
>>>
>>> --
>>> PHP Internals - PHP Runtime Development Mailing List
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>>
>>
>> --
>> PHP Internals - PHP Runtime Development Mailing List
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
>
> --
> Tom Boutell
> P'unk Avenue
> 215 755 1330
> punkave.com
> window.punkave.com
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to