Skip to content

Instantly share code, notes, and snippets.

@deepfryed
Created August 29, 2010 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepfryed/556829 to your computer and use it in GitHub Desktop.
Save deepfryed/556829 to your computer and use it in GitHub Desktop.
#include <ruby.h>
VALUE blocking_function(void *data) {
throw "die die die";
}
VALUE run(VALUE self) {
try {
rb_thread_blocking_region(blocking_function, 0, 0, 0);
}
catch (const char *e) {
printf("caught: %s\n", e);
}
return Qtrue;
}
extern "C" {
void Init_tbr() {
VALUE mTBR = rb_define_module("TBR");
rb_define_module_function(mTBR, "run", RUBY_METHOD_FUNC(run), 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment