The different framework decide c/go have to be in different loop ,,    a c
loop and a go loop.
It is hard to change that,

2017-04-28 16:17 GMT+08:00 <djad...@gmail.com>:

>
>
> On Friday, April 28, 2017 at 9:18:03 AM UTC+3, hui zhang wrote:
>>
>> How let go and c code work Alternately in the same thread with
>> goroutine(corouting mechanism)
>> Check the code below.  c and go code in one thread they just do work 1 by
>> 1.
>> Expected Result
>>
>>> Do CWork
>>> Do GoWork
>>> Do CWork
>>> Do GoWork
>>> Do CWork
>>> .....
>>
>>
>> //c code
>>> void CWork() {
>>> while(1) {
>>>    --Print Do CWork
>>>    --Coroutine Stop
>>>     --switch to GoWork()
>>> }
>>> }
>>> int main() {
>>> CWork();
>>> }
>>> //go code
>>> func GoWork() {
>>> for {
>>>     --Print Do GoWork
>>>    --Coroutine Stop
>>>     --switch back to CWork()
>>> }
>>> }
>>
>>
>>
>>
>
>
> Hi, simplest solution:
>
> //c code
>> void CWork() {
>>         --Print Do CWork
>> }
>> int main() {
>>         for {
>>         C.CWork()
>> GoWork()
>>         }
>> }
>>
>> //go code
>> func GoWork() {
>>         --Print Do GoWork
>> }
>
>
>
>  Djadala
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/Yaay2_UaIxU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to