Skip to content

Instantly share code, notes, and snippets.

@dfyx
Created April 7, 2013 22:59
Show Gist options
  • Select an option

  • Save dfyx/5332962 to your computer and use it in GitHub Desktop.

Select an option

Save dfyx/5332962 to your computer and use it in GitHub Desktop.

Revisions

  1. dfyx created this gist Apr 7, 2013.
    43 changes: 43 additions & 0 deletions main.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    rbrgss_lib = '/Users/dfyx/Projects/ruby/rbrgss/rbrgss/lib'
    $LOAD_PATH.unshift rbrgss_lib unless $LOAD_PATH.include? rbrgss_lib

    class Mutex
    # call-seq:
    # mutex.synchronize { ... }
    #
    # Obtains a lock, runs the block, and releases the lock when the
    # block completes. See the example under Mutex.
    def synchronize
    self.lock
    begin
    yield
    ensure
    self.unlock rescue nil
    end
    end
    end

    class Thread
    MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new # :nodoc:

    # call-seq:
    # Thread.exclusive { block } => obj
    #
    # Wraps a block in Thread.critical, restoring the original value
    # upon exit from the critical section, and returns the value of the
    # block.
    def self.exclusive
    MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{
    yield
    }
    end
    end

    begin
    require 'rbrgss'
    rescue LoadError => e
    puts e
    end

    RbRgss.backend = RbRgss::SDLBackend::Backend.instance
    game = RbRgss::Game.new('/Users/dfyx/Projects/ruby/rbrgss/Testprojekt')