Posts Tagged ‘Dow @ 12589.07 crazy!’

Plugin’s & Threadsafe functions

Wednesday, January 9th, 2008

    So on to plugin’s in Raydo. The computation functions I am trying to make it easier to add computation, almost like ‘plugin’s. I say ‘plugin’, and when I say plugin, I mean compiled into the code. Doing binary ‘plugins’ is just crazy. The only reason to do that is closed source code. If you have the source like Raydo, it makes much more sense to compile it in.

    So when you write a plugin, you have to worry about threads. The computations are done out in the threads, so you have to be careful to use thread safe functions.

    Certain C++ Standard Library functions from C are particular problems because they hold internal state between calls.

  • asctime
  • ctime
  • gmtime
  • localtime
  • rand
  • strtok
  • rand & strtok will probably not be a problem. The time functions (asctime, ctime, gmtime, localtime) you may end up trying to use but you shouldn’t.

        Some vendors ( like HP ) have thread-safe replacements for these functions, with different names and arguments, but you should realize that these are not portable. You can write thread-safe implementations using thread-specific storage, if you want to.

        If you really want something portable & thread safe, I suggest you use the Boost replacements for the problem functions. I will go into why I am not including Boost in the build at a later time.