ocean.core.MessageFiber

Wraps a Fiber allowing to pass a message on suspending/resuming and to kill the fiber.

Allows passing a message from suspend() to resume() and vice versa. Provides a kill() method where kill() resumes suspend() and suspend() throws a KilledException when it was resumed by kill().

suspend() and resume() require you to pass a 'token' parameter to them which must be the same for each suspend/resume pair. This prevents that a fiber is resumed from a part of the code that wasn't intended to do so.

Still, sometimes the correct position in a code could resume a fiber that was waiting for a resume from another instance of the same code (for example, a fiber is being resumed from a wrong class instance). To catch these cases, a runtime-identifier parameter was added, which is just an Object reference. If another object is resuming a fiber an exception is thrown.

See also the documentation of suspend/resume.

Debugging: You can use -debug=MessageFiber to print the identifiers that were used in the suspend/resume calls. It uses the FirstNames functions to print pointers as names.

You can use -debug=MessageFiberDump to enable a function called 'dumpFibers' which can be called from within gdb using 'call dumpFibers()'. The performance impact should be relatively low. It will output a list on STDERR listing all fibers and some informations about their state.

Example output:

Tomsen: State: TERM; Token: GroupRequest; LastSuspend: 1364929361 (157s ago); Addr: 7ff6c9ec8f00; Suspender: Actor0 Marine: State: TERM; Token: io_ready; LastSuspend: 1364929357 (161s ago); Addr: 7ff6c9eef100; Suspender: Actor1 Robert: State: TERM; Token: io_ready; LastSuspend: 1364929357 (161s ago); Addr: 7ff6c9f94a00; Suspender: Actor1 Batman: State: HOLD; Token: io_ready; LastSuspend: 1364929357 (161s ago); Addr: 7ff6c9f94300; Suspender: Actor1 Mary: State: TERM; Token: event_fired; LastSuspend: 1364929357 (161s ago); Addr: 7ff6c9fc7c00; Suspender: Actor3 Methew: State: HOLD; Token: io_ready; LastSuspend: 1364929357 (161s ago); Addr: 7ff6c9fc7500; Suspender: Actor1 Superman: State: HOLD; Token: DrizzleData; LastSuspend: 1364929515 (3s ago); Addr: 7ff6cad40800; Suspender: Actor2 Methew: State: HOLD; Token: DrizzleData; LastSuspend: 1364929515 (3s ago); Addr: 7ff6cad40600; Suspender: Actor2

Members

Classes

MessageFiber
class MessageFiber

Functions

dumpFibers
void dumpFibers()

Dump information about fibers to STDERR

Meta

License

Boost Software License Version 1.0. See LICENSE_BOOST.txt for details. Alternatively, this file may be distributed under the terms of the Tango 3-Clause BSD License (see LICENSE_BSD.txt for details).