Squirrel

The programming language
Welcome to Squirrel Sign in | Join | Help
in Search

How to Use Sqplus At Multi-Thread Environment Without Lock?

Last post 07-04-2008, 12:15 PM by fagiano. 1 replies.
Sort Posts: Previous Next
  •  07-04-2008, 1:41 AM 2605

    How to Use Sqplus At Multi-Thread Environment Without Lock?

    Hi, dear all.
    I am trying to use sqplus in multi-thread program.
    When there are two thread access SquirrelVM at the same time, the program will be crashed.
    Because of  the design purpose, all thread will access SquirrelVM frequently, I can't lock thread and wait it done, it will cause performance down.
    Do the any suggestion or any other way can solve my problem?

    Thanks.

  •  07-04-2008, 12:15 PM 2606 in reply to 2605

    Re: How to Use Sqplus At Multi-Thread Environment Without Lock?

    Hi

    Squirrel is not thread safe and neither is SQPlus. Why? There isn't a resonably fast way to make a
    dynamic language hardware thread aware, at least in the canonical procedural way.
    Some laungage wraps all the API in a critical section so that the api can be invoked by different threads, I personally believe that the application writer can do a much better job; so I decided to not even try to address the problem.
    My suggestion is: use a VM fo a single thread only you can call sq_open() in different threads and create separated VMs, but i'd stick to 1 VM, 1 hardware thread.

    ciao
    Alberto

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems