GithubHelp home page GithubHelp logo

sunaku / ruby-coroutine-example Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 1.0 125 KB

How to embed Ruby inside C coroutines.

Home Page: https://bugs.ruby-lang.org/issues/2294

C 72.28% Ruby 12.21% Shell 15.51%

ruby-coroutine-example's Introduction

This example shows how to embed Ruby using different C coroutine libraries:

* libpcl    http://www.xmailserver.org/libpcl.html
* pthread   https://computing.llnl.gov/tutorials/pthreads/
* ucontext  http://www.gnu.org/s/libc/manual/html_node/System-V-contexts.html

That are initialized using two distinct stack allocation methods:

* static    The coroutine stack is baked into the shared object file.
* dynamic   The coroutine stack is allocated dynamically, at runtime.

And optionally using my ruby_bind_stack() patch for Ruby 1.9.x, if present:

* https://github.com/sunaku/ruby/compare/trunk...2294_bind_stack.patch

* http://bugs.ruby-lang.org/issues/show/2294

******************************************************************************
*   NOTE: Without the above patch, this example WILL FAIL for Ruby 1.9.x!    *
******************************************************************************

To run this example, use the provided `run.sh` script:

    sh run.sh   # displays usage info

    sh run.sh pcl static ~/.rvm/rubies/*
    sh run.sh pcl dynamic ~/.rvm/rubies/*

    sh run.sh pthread static ~/.rvm/rubies/*
    sh run.sh pthread dynamic ~/.rvm/rubies/*

    sh run.sh ucontext static ~/.rvm/rubies/*
    sh run.sh ucontext dynamic ~/.rvm/rubies/*

I hope this helps you learn how to embed Ruby inside C coroutines.  Enjoy!

ruby-coroutine-example's People

Contributors

sunaku avatar

Stargazers

ccmywish avatar  avatar Angus H. avatar debbbbie avatar Juanito Fatas avatar luikore avatar Slavik Shynkarenko avatar  avatar Shai Rosenfeld avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

plumpmath

ruby-coroutine-example's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.