package - Tcl: Interaction of extension loading and threads -


can several instances of tcl_packageinitproc() executing concurrently (in different threads), if tcl configured threads?

for reasons of backward compatibility, believe invocations of initialization , unload procedures must serialized.

the manual silent on behavior: invocations of these routines serialized, or must extension writers deal synchronization, in particular mutual exclusion, in these routines?

tcl not guarantee functions called in serialized way; if code cares, must use suitable mutex. tcl provides portable primitives in c library, use this:

#include <tcl.h>  // easier have own function static void onetimesetup(void) {     static int donesetup;     tcl_declare_mutex(mymutex);      tcl_mutexlock(&mymutex);     if (!donesetup) {         // critical once-only setup here         donesetup = 1;     }     tcl_mutexunlock(&mymutex); }  int my_init(tcl_interp *interp) {     // declare api version we're using, e.g., 8.5...     if (tcl_initstubs(interp, "8.5", 0) == null)         return tcl_error;      // call out our setup code     onetimesetup();      // install tcl commands/variables/... here      // ready action!     return tcl_ok; } 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -