goodeggs/cls-fibers — pull request #6 by adborden (2014-12-22 23:10:38+00:00)
Title: Preserve continuation chain

Swap the CLS Chain between fiber operations. Model the Fiber operations as run, yield, resume, end. Would appreciate any comments on the general strategy, how to be defensive about errors (error handling is currently missing) and any other thoughts.

## CLSChain
Represents a chain of CLS contexts to preserve the enter/exit context stack. Each Chain creates a copy of the current state. You can update it with `save()` or "make it active" with `restore()`

## FiberCLS
Models fiber operations with respect to CLS.

### run()
Called when the fiber is run for the first time only. It preserves the pre-fiber CLS chain to be restored when the fiber yields or ends. It also enters the fiber CLS context.

### yield()
Called when the fiber yields (Fiber.yield). It saves the fiber CLS chain to be restored when the fiber resumes. Then it restores the preserved pre-fiber state.

### resume()
Called when the fiber resumes (Fiber::run after a Fiber.yield). it saves the pre-fiber CLS chain and restores the saved fiber CLS chain.

### end()
Called when the fiber ends (The fiber function returns without a Fiber.yield). It exits the fiber context and restores the pre-fiber CLS chain.