On Tue, Nov 12, 2013 at 6:32 PM, Jerry <lancebo...@qwest.net> wrote: > I posted an announcement some time back on comp.lang.ada. about the latest > PLplot release. (FWIW, it currently has 182 views, and I got some useful > feedback from the Ada gurus.) > > Today this post (below) appeared. I don't know how to answer his question > about thread safety. Any thoughts? > > Jerry > > > > > Hi Jerry, > > That looks really interesting. > > I'm looking for a plotter routine that could be used safely inside the AWS [= > Ada Web Server] web server, so I can implement a 'callback' chart server > (currently I have one written in Java). > > Could this be used for that? Some simple tests suggest to me that it isn't > thread safe. The Initialize_PLplot [aka plinit] and associated procedures to > set filenames, etc, seem to set global variables somewhere. Is there some > trick I'm missing? > > It does make lovely looking charts. > > thanks very much for this. > > Graham
PLplot is not thread safe. While you can use PLplot in a threaded program, only one thread per process may interact with PLplot at a given time. This limitation holds even if you are working with multiple plot streams in a single process. Regarding Alan's follow-up - while it is possible to make PLplot thread-safe, the changes required are invasive and pervasive. They are all good changes to make! But there is a lot to be done and the result is a completely backwards-incompatible API. The three big pieces required are: a) All PLplot functions will need to explicitly operate on a given plstream value representing the affected plot stream. This requires adding an additional stream argument to all PLplot functions and removing any global state from plot streams. b) Remove all of the globals used through the PLplot code base in the actual plotting logic. One example is the contour/shading routines which use several global variables to track their state. c) Confirm/ensure that each of our output devices can be and are used in a thread-safe manner. Each of these big pieces is made up of several smaller chunks. (a) is where the API breakage would come in. It is also likely the simplest (simple being relative here!) to complete. (b) could be pretty hairy as the logic in the contouring routines in particular is tricky to translate to something which doesn't use globals. (c) should be attainable for at least the Cairo, Qt and built-in output drivers (SVG, PS, null). I would be happy to help in putting together a plan for this work. Unfortunately my PLplot time is very limited these days so it's unlikely I'll be able to provide much development assistance. Hez ------------------------------------------------------------------------------ DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel