IronLanguages / ironruby

98 stars 24 forks source link

Fiber Support? #9

Open aphadeon opened 8 years ago

aphadeon commented 8 years ago

When attempting to create a Fiber in IronRuby, I get an undefined constant error for the name Fiber. I've tried searching, and made sure to load the threading library in case it was in there.

I am emulating an existing engine whose scripts make use of Fiber; before resorting to trying to implement it myself, I want to be sure I'm not just missing something.

So my question is, does IronRuby support, or plan to support, the Fiber class?

Worth noting that I've tried both the official binaries as well as building from source.

I was able to find this, in case anyone else has a similar issue. Significantly less performant, but works in a pinch: https://gist.github.com/tmm1/4631

Would like to know if it is supported, planned, or not supported, as searching the topic yields very little information.

aphadeon commented 8 years ago

Moved this issue from https://github.com/IronLanguages/main/issues/1195

amiralles commented 8 years ago

Hi @avarisc I'll investigate this one the next week. If is not supported right now, it'll be at the future. Not sure how much effort/time will take, though. (After a brief inspection of MRI's implementation you can tell for sure that is not the easiest thing to do, but is not impossible either).

PS: Been a long since I look at this code base (six years or so), so it may take a while, but eventually I'll get up to speed and get back at you.

amiralles commented 7 years ago

Hey @avarisc, I been doing a copule of experiments trying to implement this feature, and the bad news is, since that there's no builtin support for fibers on .NET, there is no way to implement this feature in any reliable way. There are some "hackie" solutions out there, such as emulate fibers with iterators or direct calls to the Windows Fiber API, but none of them convinced me.... I'll keep working on this and try what JRuby does (use threads instead of fibers) but I'm not sure if ever is gonna make it to prod. Sorry.

aphadeon commented 7 years ago

A thread-based solution might be worthwhile for compatibility, if nothing else. Not familiar with JRuby's internals, but having a nonperformant Fiber class might be preferable to Fiber simply not existing? Either way, I appreciate your effort on this.

amiralles commented 7 years ago

My pleasure. With regards to JRuby's Fiber implementation, that's exactly what they say; "While is not optimal, a thread based Fiber implementation is better than not having Fiber at all". I'll keep looking at this and let you to know if I make any progress.

On 26 September 2016 at 11:53, Jason B. notifications@github.com wrote:

A thread-based solution might be worthwhile for compatibility, if nothing else. Not familiar with JRuby's internals, but having a nonperformant Fiber class might be preferable to Fiber simply not existing? Either way, I appreciate your effort on this.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/IronLanguages/ironruby/issues/9#issuecomment-249593502, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBcdDkSz7IkKa2Wz3SuTjxIT2FpYNbdks5qt9xQgaJpZM4JNge_ .