Questions tagged [fiber]

Fibers are particularly lightweight threads of execution which use co-operative multitasking.

In computer science, a fiber is a particularly lightweight thread of execution..

Like threads, fibers share address space. However, fibers use co-operative multitasking while threads use pre-emptive multitasking. Threads often depend on the kernel's thread scheduler to preempt a busy thread and resume another thread; fibers yield themselves to run another fiber while executing. The article on threads contains more on the distinction between threads and fibers.

Fibers can be considered as implementation of coroutines so you might like to check also [coroutine] tag.

98 questions
1
vote
0 answers

A fiber issue with `autoload`: `fiber called across stack rewinding barrier (FiberError)`

We are using fiber with eventmachine (em-synchrony) in our production env for quite a long time, and it works very well. We use the outdated ruby 1.9.3 and ActiveRecord 3.x for over 2 years. We are migrating those two big parts to the latest…
qqshfox
  • 11
  • 2
1
vote
1 answer

Reuse a Fiber in Ruby

I use EventMachine.open_keyboard in my irc client app that uses rbcurse (ncurses gem), as follows: Fiber.new do EM.open_keyboard(NbKeyboard) do |kb| $input = Readline.readline("") $buffer << $input end end.resume This code…
1
vote
1 answer

Ruby fiber "dead fiber called"

Playing round with fibers and I know I'm doing something stupid here. But trying to create a simple enumerable type thing based on fibers (it's obviously trivial using Enumerable). When I run the following I get a dead fiber error after it prints…
rainkinz
  • 10,082
  • 5
  • 45
  • 73
1
vote
1 answer

Why does this fiber behaves this way

In this code: fiber = Fiber.new do |first, second| num = Fiber.yield first + second + 2 end puts fiber.resume 5, 4 puts fiber.resume 3 The output is 11 and 3 each on a separate line. I understand why the output is 11 for the first fiber.resume…
daremkd
  • 8,244
  • 6
  • 40
  • 66
1
vote
1 answer

Meteor error: Fiber is not defined

I use fiber wrapper for async calls, for example when I need make record in database. But today I have an error: "Fiber is not defined.". I try reinstall fiber with npm but this is doesn't help me.
Denis
  • 7,127
  • 8
  • 37
  • 58
1
vote
1 answer

django-fiber content template

I'm currently implementing Django-fiber on a project of ours. However I find the documentation very lacking. I'm trying to use custom content-templates for different chunks of content on the site. I've added the FIBER_CONTENT_TEMPLATE_CHOICES =…
Erik Svedin
  • 1,286
  • 12
  • 26
1
vote
0 answers

How to raise StopIteration repeatedly from Ruby fiber

The following Ruby fiber raises a StopIteration exception the first time it is resumed, but not subsequently. Is it possible to make a fiber which raises the exception every time it is resumed? f = Fiber.new do while true raise StopIteration …
Joe Nelson
  • 549
  • 5
  • 12
0
votes
2 answers

Why does the implementation of user level thread (fiber) require a new allocated stack per fiber?

In C fibers can be coded using setjmp() and longjmp() to implement context switches at user level. As described in evanjones.ca and Portable Multithreading(pdf) it is also required that each fiber has a newly allocated stack. Since a fiber lives in…
Angelo
  • 334
  • 4
  • 14
0
votes
1 answer

How to create a fiber using 'method' instead of a code block

Instead of doing this, @fiber = Fiber.new do # ... end I am trying to do something like this: def test yield # ... end def create(process) @fiber = Fiber.new(process) end create(method(:test)) How can I make the Fiber code look like the…
JustWe
  • 4,250
  • 3
  • 39
  • 90
0
votes
2 answers

Prevent ffmpeg from taking over stdout

When I do system "ffmpeg -i just-do-it.mp4 -ab 96k -ar 22050 -qscale 6 output.flv" ffmpeg takes over the ruby process till the job is done, which sometimes take a long time. I've tried using threads amd fork in Ruby to no avail, also system…
sent-hil
  • 18,635
  • 16
  • 56
  • 74
0
votes
1 answer

Producer/Consumer using Boost.Fibers

I'm trying to create producer/consumer using Boost.Fibers. Looks like using channels from this example is the right thing to do. The example have to be changed slightly since I want to signal completion using promise/future. So I wrote some naive…
kreuzerkrieg
  • 3,009
  • 3
  • 28
  • 59
0
votes
1 answer

[ 'Parse error: Can\'t wait without a fiber' ]' When trying to do find within Metor

When receiving JSON data via websockets, I'm trying to feed this data into a mongodb within meteor. I'm getting the JSON data fine, but when trying to find whether the data already exists in the database, I keep getting the error: "[ 'Parse error:…
RufusWhite
  • 13
  • 3
0
votes
2 answers

Does Boost.Fiber automatically yield on network requests, such as a database call over the network?

Does Boost.Fiber automatically yield on network requests (if I understand correctly they yield the CPU during I/O), such as a database call over the network? I want to use it for setting up blocking database calls where I am inserting a lot of…
Halcyon
  • 1,376
  • 1
  • 15
  • 22
0
votes
1 answer

Quasar fiber - difference between join() and get()

The title says it all. There's no explicit instructions on these two methods as to which should be used.
user6332430
  • 442
  • 10
  • 29
0
votes
1 answer

How can I output specific bitstream of data to a SFP+ NIC module?

I want to output a stream of 1's and 0's to a fiber optic SFP+ module through a NIC connected to my workstation computer ( can be Windows or CentOS/Linux), where and how do I get started? Any name of software to use for this? Thanks for any…