Giter Club home page Giter Club logo

Comments (5)

oubidar-Abderrahim avatar oubidar-Abderrahim commented on June 20, 2024

Hi, Thank you for reporting this. Please take a look at this: Multithreading
Let us know if that answers your question

from graaljs.

vepo avatar vepo commented on June 20, 2024

Thanks @oubidar-Abderrahim, but this wiki page does not answer my question. My issue is that we create some classes in our Javascript code that are called by another framework (Kafka Streams). We could not find a way to synchronize these threads or create on context per thread.

from graaljs.

oubidar-Abderrahim avatar oubidar-Abderrahim commented on June 20, 2024

Hi @iamstolis can you take a look into this please?

from graaljs.

iamstolis avatar iamstolis commented on June 20, 2024

Is there a way to provide Class (or Context) factory to avoid using the same context in different threads?

No. You should not use the same (graal-js) ScriptEngine in multiple threads without a proper synchronization. I suggest you to either use one ScriptEngine per thread or synchronize the access to one global ScriptEngine.

We could not find a way to synchronize these threads ...

If I understand correctly then your problem is that some framework is using ScriptEngine (that you provide) from multiple threads. You may try to provide your own implementation of ScriptEngine that delegates to graal-js ScriptEngine. The methods of your wrapper could either synchronize the access or delegate to per-thread graal-js ScriptEngines (that your wrapper ScriptEngine will create/manage).

from graaljs.

vepo avatar vepo commented on June 20, 2024

@iamstolis, I'm not sure if you understand correctly.

your problem is that some framework is using ScriptEngine (that you provide) from multiple threads.

No. We have a framework using ScriptEngine that does not create the threads, it provides some classes that will be used by other threads. The threads are created by another framework, in our case Kafka Streams.

In my sample, I have the onCustom function that receives a stream and creates some classes on this stream. The function provided on filter will be used in many classes. I can configure my Kafka Stream to use just one thread, but this is not a good scenario for scaling.

from graaljs.

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.