summaryrefslogtreecommitdiffstats
path: root/win/tclWinInt.h
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-01 08:47:57 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-01 08:47:57 (GMT)
commitda02e63f0ab94d965d72f687788adf41de420957 (patch)
tree2777253542c057852616cdbdfe6c3261ded7baf8 /win/tclWinInt.h
parent76e8da363bc1d0cdfad2b3d1a3e0f8024ff09da1 (diff)
parent799554b1c55435a6c7cc1f4529d3e468106b9091 (diff)
downloadtcl-da02e63f0ab94d965d72f687788adf41de420957.zip
tcl-da02e63f0ab94d965d72f687788adf41de420957.tar.gz
tcl-da02e63f0ab94d965d72f687788adf41de420957.tar.bz2
Merge trunk
Diffstat (limited to 'win/tclWinInt.h')
-rw-r--r--win/tclWinInt.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/win/tclWinInt.h b/win/tclWinInt.h
index b1c6d26..4ae6fe2 100644
--- a/win/tclWinInt.h
+++ b/win/tclWinInt.h
@@ -100,4 +100,70 @@ MODULE_SCOPE void TclpSetAllocCache(void *);
#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
#endif
+/*
+ *----------------------------------------------------------------------
+ * Declarations of helper-workers threaded facilities for a pipe based channel.
+ *
+ * Corresponding functionality provided in "tclWinPipe.c".
+ *----------------------------------------------------------------------
+ */
+
+typedef struct TclPipeThreadInfo {
+ HANDLE evControl; /* Auto-reset event used by the main thread to
+ * signal when the pipe thread should attempt
+ * to do read/write operation. Additionally
+ * used as signal to stop (state set to -1) */
+ volatile LONG state; /* Indicates current state of the thread */
+ ClientData clientData; /* Referenced data of the main thread */
+ HANDLE evWakeUp; /* Optional wake-up event worker set by shutdown */
+} TclPipeThreadInfo;
+
+
+/* If pipe-workers will use some tcl subsystem, we can use ckalloc without
+ * more overhead for finalize thread (should be executed anyway)
+ *
+ * #define _PTI_USE_CKALLOC 1
+ */
+
+/*
+ * State of the pipe-worker.
+ *
+ * State PTI_STATE_STOP possible from idle state only, worker owns TI structure.
+ * Otherwise PTI_STATE_END used (main thread hold ownership of the TI).
+ */
+
+#define PTI_STATE_IDLE 0 /* idle or not yet initialzed */
+#define PTI_STATE_WORK 1 /* in work */
+#define PTI_STATE_STOP 2 /* thread should stop work (owns TI structure) */
+#define PTI_STATE_END 4 /* thread should stop work (worker is busy) */
+#define PTI_STATE_DOWN 8 /* worker is down */
+
+
+MODULE_SCOPE
+TclPipeThreadInfo * TclPipeThreadCreateTI(TclPipeThreadInfo **pipeTIPtr,
+ ClientData clientData, HANDLE wakeEvent);
+MODULE_SCOPE int TclPipeThreadWaitForSignal(TclPipeThreadInfo **pipeTIPtr);
+
+static inline void
+TclPipeThreadSignal(
+ TclPipeThreadInfo **pipeTIPtr)
+{
+ TclPipeThreadInfo *pipeTI = *pipeTIPtr;
+ if (pipeTI) {
+ SetEvent(pipeTI->evControl);
+ }
+};
+
+static inline int
+TclPipeThreadIsAlive(
+ TclPipeThreadInfo **pipeTIPtr)
+{
+ TclPipeThreadInfo *pipeTI = *pipeTIPtr;
+ return (pipeTI && pipeTI->state != PTI_STATE_DOWN);
+};
+
+MODULE_SCOPE int TclPipeThreadStopSignal(TclPipeThreadInfo **pipeTIPtr, HANDLE wakeEvent);
+MODULE_SCOPE void TclPipeThreadStop(TclPipeThreadInfo **pipeTIPtr, HANDLE hThread);
+MODULE_SCOPE void TclPipeThreadExit(TclPipeThreadInfo **pipeTIPtr);
+
#endif /* _TCLWININT */