Using fibers

2018-08-03 Thread solidstate1991 via Digitalmars-d-learn
I'm porting LZHAM to D, and the original used some very unusual 
approach for coroutines:
 - the whole thing is running inside of a single switch-case 
block created by C++ macros

 - the function saves some local values
 - a macro sets the state variable to the current line number, 
returns the status (eg. if compression error happened or the 
decompressor needs more data), then the function can be continued 
from a new case block labelled by __LINE__


I started to switch out error codes with exceptions, at least 
they also provide more information besides what happened, but 
don't know what should the fate of the other status codes be. I 
probably making them derived from the Throwable class to 
distinguish them from the error codes, or put delegates in place 
of them. I hope the Fiber class will eliminate the ugliness of 
the macro-generated switch-case block, and make the code easier 
to read and debug.


SegFaults when using Fibers

2011-08-10 Thread Danny Arends
(Also posted this in bugs, but I think it needs to be here)

When I try to print floats and doubles from a fiber it fails with a
segfault, while it is possible to do the same in the main thread.

The expected output of the attached code file:
15
15
Done

However I get:
15
segfault

I am using the DMD64 D Compiler v 2.054 on Debian 64

What am I doing wrong, because using to!string() on the floats and
double allows me to print them to std.out.

I however get weird behavior when I try to do math on the floats and
doubles in the fiber, or when I pass them to C-functions.

Any Help would be appreciated
Kind regards,
Danny
begin 644 test.d
M+RHJ"B`J($)U9R!R97!OPIP=6)L:6,Z"B`@=&AIR!S=7!E#T@,3`["B`@("!I;G0@>3T@-3L*("`@(&9L;V%T
M(&UY9&]U8FQE(#T@>"MY.PH@("`@=W)I=&5L;BAM>61O=6)L92D[("\O5&AI
M

Re: SegFaults when using Fibers

2011-08-10 Thread simendsjo

On 10.08.2011 11:53, Danny Arends wrote:

(Also posted this in bugs, but I think it needs to be here)


The bugs newsgroup should be read-only.
Post bugs here: http://d.puremagic.com/issues/
Events in bugzilla gets posted to the bugs newsgroup



Re: SegFaults when using Fibers

2011-08-10 Thread Danny Arends
OK
Thanks very much, made myself an account there and
re-posted the issue.

Though it still feels like I'm doing something wrong


Re: SegFaults when using Fibers

2011-08-10 Thread Kagamin
Danny Arends Wrote:

> OK
> Thanks very much, made myself an account there and
> re-posted the issue.

Not OK. You forgot testcase.