[quickjs-devel] Re: quickjs & threads

  • From: Alexander Mihalicyn <alexander@xxxxxxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Thu, 23 Jan 2020 09:30:42 -0800

QuickJS code is not thread-safe. You could not use the same JSContext
structure in two threads simultaneously.

On Thu, Jan 23, 2020 at 8:57 AM JM <jeevhi@xxxxxxxxx> wrote:


Consider the scenario,

Launched Thread 1 {
        Create JSContext
        Eval JavaScript
         Save context somewhere
}

After sometime,

Launch Thread 2 {
            retrieve context saved from Thread 1
            Call some JS function using JSCall()
}

Since both the threads are not running simultaneously, I expected this to 
work but it doesn't. Instead, JSCall() generates exception.

Any idea ?

Other related posts: