}
+#ifdef WITH_THREAD
static void
Tkapp_ThreadSend(TkappObject *self, Tcl_Event *ev,
Tcl_Condition *cond, Tcl_Mutex *mutex)
Tcl_MutexUnlock(mutex);
Py_END_ALLOW_THREADS
}
+#endif
\f
/** Tcl Eval **/
return newPyTclObject(value);
}
+#ifdef WITH_THREAD
/* This mutex synchronizes inter-thread command calls. */
-
TCL_DECLARE_MUTEX(call_mutex)
typedef struct Tkapp_CallEvent {
PyObject **exc_type, **exc_value, **exc_tb;
Tcl_Condition *done;
} Tkapp_CallEvent;
+#endif
void
Tkapp_CallDeallocArgs(Tcl_Obj** objv, Tcl_Obj** objStore, int objc)
return res;
}
+#ifdef WITH_THREAD
+
/* Tkapp_CallProc is the event procedure that is executed in the context of
the Tcl interpreter thread. Initially, it holds the Tcl lock, and doesn't
hold the Python lock. */
return 1;
}
+#endif
+
/* This is the main entry point for calling a Tcl command.
It supports three cases, with regard to threading:
1. Tcl is not threaded: Must have the Tcl lock, then can invoke command in
\f
/** Tcl Variable **/
+typedef PyObject* (*EventFunc)(PyObject*, PyObject *args, int flags);
+
+#ifdef WITH_THREAD
TCL_DECLARE_MUTEX(var_mutex)
-typedef PyObject* (*EventFunc)(PyObject*, PyObject *args, int flags);
typedef struct VarEvent {
Tcl_Event ev; /* must be first */
PyObject *self;
PyObject **exc_val;
Tcl_Condition *cond;
} VarEvent;
+#endif
static int
varname_converter(PyObject *in, void *_out)
return 0;
}
+#ifdef WITH_THREAD
+
static void
var_perform(VarEvent *ev)
{
return 1;
}
+#endif
+
static PyObject*
var_invoke(EventFunc func, PyObject *selfptr, PyObject *args, int flags)
{
- TkappObject *self = (TkappObject*)selfptr;
#ifdef WITH_THREAD
+ TkappObject *self = (TkappObject*)selfptr;
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
TkappObject *self = (TkappObject*)selfptr;
VarEvent *ev;
\f
+#ifdef WITH_THREAD
TCL_DECLARE_MUTEX(command_mutex)
typedef struct CommandEvent{
Tcl_MutexUnlock(&command_mutex);
return 1;
}
+#endif
static PyObject *
Tkapp_CreateCommand(PyObject *selfptr, PyObject *args)
Py_INCREF(func);
data->self = selfptr;
data->func = func;
-
+
+#ifdef WITH_THREAD
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
Tcl_Condition cond = NULL;
CommandEvent *ev = (CommandEvent*)ckalloc(sizeof(CommandEvent));
Tkapp_ThreadSend(self, (Tcl_Event*)ev, &cond, &command_mutex);
Tcl_ConditionFinalize(&cond);
}
- else {
+ else
+#endif
+ {
ENTER_TCL
err = Tcl_CreateCommand(
Tkapp_Interp(self), cmdName, PythonCmd,
if (!PyArg_ParseTuple(args, "s:deletecommand", &cmdName))
return NULL;
+
+#ifdef WITH_THREAD
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
Tcl_Condition cond = NULL;
CommandEvent *ev;
&command_mutex);
Tcl_ConditionFinalize(&cond);
}
- else {
+ else
+#endif
+ {
ENTER_TCL
err = Tcl_DeleteCommand(self->interp, cmdName);
LEAVE_TCL