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
6
votes
1 answer

Fiber#alive? not defined

I use ruby1.9.2p180 (2011-02-18 revision 30909) i686-linux. Fiber#alive? returns an undefined error: fiber = Fiber.new{puts 'hello'} fiber.alive? => undefined error Other methods, for example, Fiber#resume , Fiber.yield seem to be working fine.…
sawa
  • 165,429
  • 45
  • 277
  • 381
6
votes
2 answers

Ruby concurrency/asynchronous processing (with simple use case)

I was looking into ruby's parallel/asynchronous processing capabilities and read many articles and blog posts. I looked through EventMachine, Fibers, Revactor, Reia, etc, etc. Unfortunately, I wasn't able to find a simple, effective (and…
Dim
  • 61
  • 2
6
votes
1 answer

Meteor [Error: Can't wait without a fiber] after a call to Email.send

I've created a very simple server using Meteor, to send an email after a timeout. When I use a timeout, the message is successfully sent but an error is thrown: [Error: Can't wait without a fiber]. Here's my code: if (Meteor.isServer) { …
James Newton
  • 6,623
  • 8
  • 49
  • 113
6
votes
1 answer

Mac OS equivalent of the Windows Fibers API?

I'm asking this out of curiosity. Windows provides what they call a Fibers API, which is a API for lightweight user processes/threads. I was interested in knowing if Mac OS provides such features as well. As far as I could find out, the closest Unix…
glampert
  • 4,371
  • 2
  • 23
  • 49
5
votes
0 answers

Why in Ruby 1.9 Continuations are evil?

I am relative new in Ruby world. And I don't know, what to think. In 'The Ruby Programming Language' I read I shouldn't use Continuations in new code and use Fibers instead. I found this presentation (from 2008)…
guest
  • 1,696
  • 4
  • 20
  • 31
5
votes
2 answers

Ruby fiber: resuming transferred fibers

I am trying to understand the behavior of the following code snippet. My specific focus is on the Fiber#transfer method. require 'fiber' fiber2 = nil fiber1 = Fiber.new do puts "In Fiber 1" # 3 fiber2.transfer …
CppNoob
  • 2,322
  • 1
  • 24
  • 35
5
votes
1 answer

What is a fiber cookie?

I was browsing through the .NET Marshall class, when I noticed the method GetThreadFromFiberCookie. I tried searching for the term, but only found references to Fibers in the context of threading on Windows. So what is a fiber cookie?
Simon Verbeke
  • 2,905
  • 8
  • 36
  • 55
4
votes
1 answer

SEH setup for fibers with exception chain validation (SEHOP) active

I'm working on a native fiber/coroutine implementation – fairly standard, for each fiber, a separate stack is allocated, and to switch contexts, registers are pushed onto the source context stack and popped from the target stack. It works well, but…
dnadlinger
  • 5,883
  • 4
  • 21
  • 24
4
votes
1 answer

Please explain the logic behind this ruby fiber example

The example code is from here: def http_get(url) f = Fiber.current http = EventMachine::HttpRequest.new(url).get # resume fiber once http call is done http.callback { f.resume(http) } http.errback { f.resume(http) } return…
Geo
  • 93,257
  • 117
  • 344
  • 520
3
votes
1 answer

What to do after quitting in the middle of a fiber

Once I am done in the middle of a Fiber instance fiber, i.e., I yielded from it without completing it, and I am not using fiber any more, what should I do with it? Should I explicitly destroy it, or is there something like kill for a Fiber, or will…
sawa
  • 165,429
  • 45
  • 277
  • 381
3
votes
1 answer

Do fibers have priorities?

Fibers are defined as lightweight threads, and threads have priorities because they are preemptively scheduled. However, since fibers are cooperative do they too have priorities?
3
votes
1 answer

control flow in ruby fiber program

I know that fibers are cooperative threads. A fiber has control of the execution context, whereas a preemptive thread does not. A fiber can yield control, which means a fiber can start and stop in well-defined places. Apparently, the reason why…
Daniel Viglione
  • 8,014
  • 9
  • 67
  • 101
3
votes
1 answer

How does one achieve parallel tasks with Ruby's Fibers?

I'm new to fibers and EventMachine, and have only recently found out about fibers when I was seeing if Ruby had any concurrency features, like go-lang. There don't seem to be a whole lot of examples out there for real use cases for when you'd use a…
NullVoxPopuli
  • 61,906
  • 73
  • 206
  • 352
3
votes
0 answers

"Meteor code must always run within a Fiber" when using Meteor.runAsync

Using cassandra with meteor. let client = new cassandra.Client({contactPoints: [cassandraHost]}); var cassandraExecSync = Meteor.wrapAsync(client.execute, client); MyProject.Feed.CassandraMeteorWrap = { insertNewPost: function (userId,…
3
votes
5 answers

Image-processing basics

I have to do some image processing but I don't know where to start. My problem is as follows :- I have a 2D fiber image (attached with this post), in which the fiber edges are denoted by white color and the inside of the fiber is black. I want to…
Aditya Singh
  • 93
  • 1
  • 4