Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# miniprelude.c

Go to the documentation of this file.

    00001 /* -*-c-*-
    00002  THIS FILE WAS AUTOGENERATED BY tool/compile_prelude.rb. DO NOT EDIT.
    00003
    00004  sources: prelude
    00005 */
    00006 #include "ruby/ruby.h"
    00007 #include "vm_core.h"
    00008
    00009
    00010 static const char prelude_name0[] = "<internal:prelude>";
    00011 static const char prelude_code0[] =
    00012 "class Mutex\n"
    00013 "  # call-seq:\n"
    00014 "  #    mutex.synchronize { ... }\n"
    00015 "  #\n"
    00016 "  # Obtains a lock, runs the block, and releases the lock when the\n"
    00017 "  # block completes.  See the example under Mutex.\n"
    00018 "  def synchronize\n"
    00019 "    self.lock\n"
    00020 "    begin\n"
    00021 "      yield\n"
    00022 "    ensure\n"
    00023 "      self.unlock rescue nil\n"
    00024 "    end\n"
    00025 "  end\n"
    00026 "end\n"
    00027 "\n"
    00028 "class Thread\n"
    00029 "  MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new # :nodoc:\n"
    00030 "\n"
    00031 "  # call-seq:\n"
    00032 "  #    Thread.exclusive { block }   => obj\n"
    00033 "  #  \n"
    00034 "  # Wraps a block in Thread.critical, restoring the original value\n"
    00035 "  # upon exit from the critical section, and returns the value of the\n"
    00036 "  # block.\n"
    00037 "  def self.exclusive\n"
    00038 "    MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{\n"
    00039 "      yield\n"
    00040 "    }\n"
    00041 "  end\n"
    00042 "end\n"
    00043 ;
    00044
    00045 #define PRELUDE_COUNT 0
    00046
    00047
    00048 VALUE rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE filepath, VALUE line, VALUE opt);
    00049
    00050 static void
    00051 prelude_eval(VALUE code, VALUE name, VALUE line)
    00052 {
    00053     rb_iseq_eval(rb_iseq_compile_with_option(code, name, Qnil, line, Qtrue));
    00054 }
    00055
    00056 void
    00057 Init_prelude(void)
    00058 {
    00059     prelude_eval(
    00060       rb_usascii_str_new(prelude_code0, sizeof(prelude_code0) - 1),
    00061       rb_usascii_str_new(prelude_name0, sizeof(prelude_name0) - 1),
    00062       INT2FIX(1));
    00063
    00064 #if 0
    00065     puts(prelude_code0);
    00066 #endif
    00067 }
    00068