Code Monkey home page Code Monkey logo

Comments (4)

erikh avatar erikh commented on August 28, 2024 1

ok, this actually ends up being a problem with the mrb object not being re-entrant... in mruby itself when entered externally with load_string. I'm not entirely certain this would work with mruby without golang either.

Conversely, this code executes just fine, allocating a single interpreter per goroutine:

// main.go

package main

import (
	"sync"

	"github.com/mitchellh/go-mruby"
)

func main() {

	var wg sync.WaitGroup

	for i := 1; i < 50000; i++ {
		wg.Add(1)

		go func() {
			mrb := mruby.NewMrb()
			defer mrb.Close()
			mrb.LoadString("puts 'hola mundo'")
			wg.Done()
		}()
	}

	wg.Wait()
}

since this is a resolution you can take today, I strongly suggest you take it. You can wrap mutual accesses with mutex locks of your own devising, allowing you to load code sequentially from different goroutines. Alternatively, you can feed that code through a channel and load it serially.

we can do this as well; I just need to think of the situations that can go wrong by embedding a mutex in the struct around these operations, and whether or not it's better to just say "deal with it yourself". If other maintainers have a solution they like, please chime in.

from go-mruby.

erikh avatar erikh commented on August 28, 2024

from go-mruby.

erikh avatar erikh commented on August 28, 2024

from go-mruby.

erikh avatar erikh commented on August 28, 2024

did this ever get fixed?

from go-mruby.

Related Issues (20)

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.