diff dstep/coreservices/carboncore/Threads.d @ 11:07194b026fa4

Added bindings to a couple of frameworks, new license + some other things
author Jacob Carlborg <doob@me.com>
date Sat, 01 Aug 2009 15:03:28 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/coreservices/carboncore/Threads.d	Sat Aug 01 15:03:28 2009 +0200
@@ -0,0 +1,127 @@
+/**
+ * Copyright: Copyright (c) 2009 Jacob Carlborg.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 21, 2009 
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
+ */
+module dstep.coreservices.carboncore.Threads;
+
+//import dstep.AvailabilityMacros;
+import dstep.coreservices.carboncore.MacErrors;
+import dstep.coreservices.carboncore.MacTypes;
+import dstep.coreservices.carboncore.MixedMode;
+
+alias ushort ThreadState;
+alias void* ThreadTaskRef;
+alias uint ThreadStyle;
+alias uint ThreadID;
+alias uint ThreadOptions;
+alias SchedulerInfoRec* SchedulerInfoRecPtr;
+alias void* voidPtr;
+alias ThreadEntryProcPtr ThreadEntryUPP;
+alias ThreadSchedulerProcPtr ThreadSchedulerUPP;
+alias ThreadSwitchProcPtr ThreadSwitchUPP;
+alias ThreadTerminationProcPtr ThreadTerminationUPP;
+alias DebuggerNewThreadProcPtr DebuggerNewThreadUPP;
+alias DebuggerDisposeThreadProcPtr DebuggerDisposeThreadUPP;
+alias DebuggerThreadSchedulerProcPtr DebuggerThreadSchedulerUPP;
+alias ThreadEntryUPP ThreadEntryTPP;
+alias ThreadSchedulerUPP ThreadSchedulerTPP;
+alias ThreadSwitchUPP ThreadSwitchTPP;
+alias ThreadTerminationUPP ThreadTerminationTPP;
+alias DebuggerNewThreadUPP DebuggerNewThreadTPP;
+alias DebuggerDisposeThreadUPP DebuggerDisposeThreadTPP;
+alias DebuggerThreadSchedulerUPP DebuggerThreadSchedulerTPP;
+
+extern (C)
+{
+	alias uint function (SchedulerInfoRecPtr) ThreadSchedulerProcPtr;
+	alias void function (uint, void*) ThreadTerminationProcPtr;
+	alias void function (uint, void*) ThreadSwitchProcPtr;
+	alias void function (uint) DebuggerDisposeThreadProcPtr;
+	alias voidPtr function (void*) ThreadEntryProcPtr;
+	alias uint function (SchedulerInfoRecPtr) DebuggerThreadSchedulerProcPtr;
+	alias void function (uint) DebuggerNewThreadProcPtr;
+}
+
+enum
+{
+	kReadyThreadState = 0,
+	kStoppedThreadState = 1,
+	kRunningThreadState = 2
+}
+
+enum
+{
+	kCooperativeThread = 1L << 0,
+	kPreemptiveThread = 1L << 1
+}
+
+enum
+{
+	kNoThreadID = 0,
+	kCurrentThreadID = 1,
+	kApplicationThreadID = 2
+}
+
+enum
+{
+	kNewSuspend = (1 << 0),
+	kUsePremadeThread = (1 << 1),
+	kCreateIfNeeded = (1 << 2),
+	kFPUNotNeeded = (1 << 3),
+	kExactMatchThread = (1 << 4)
+}
+
+struct SchedulerInfoRec
+{
+	uint InfoRecSize;
+	uint CurrentThreadID;
+	uint SuggestedThreadID;
+	uint InterruptedCoopThreadID;
+}
+
+extern (C)
+{
+	ThreadEntryUPP NewThreadEntryUPP (ThreadEntryProcPtr userRoutine);
+	ThreadSchedulerUPP NewThreadSchedulerUPP (ThreadSchedulerProcPtr userRoutine);
+	ThreadSwitchUPP NewThreadSwitchUPP (ThreadSwitchProcPtr userRoutine);
+	ThreadTerminationUPP NewThreadTerminationUPP (ThreadTerminationProcPtr userRoutine);
+	DebuggerNewThreadUPP NewDebuggerNewThreadUPP (DebuggerNewThreadProcPtr userRoutine);
+	DebuggerDisposeThreadUPP NewDebuggerDisposeThreadUPP (DebuggerDisposeThreadProcPtr userRoutine);
+	DebuggerThreadSchedulerUPP NewDebuggerThreadSchedulerUPP (DebuggerThreadSchedulerProcPtr userRoutine);
+	void DisposeThreadEntryUPP (ThreadEntryUPP userUPP);
+	void DisposeThreadSchedulerUPP (ThreadSchedulerUPP userUPP);
+	void DisposeThreadSwitchUPP (ThreadSwitchUPP userUPP);
+	void DisposeThreadTerminationUPP (ThreadTerminationUPP userUPP);
+	void DisposeDebuggerNewThreadUPP (DebuggerNewThreadUPP userUPP);
+	void DisposeDebuggerDisposeThreadUPP (DebuggerDisposeThreadUPP userUPP);
+	void DisposeDebuggerThreadSchedulerUPP (DebuggerThreadSchedulerUPP userUPP);
+	voidPtr InvokeThreadEntryUPP (void* threadParam, ThreadEntryUPP userUPP);
+	uint InvokeThreadSchedulerUPP (SchedulerInfoRecPtr schedulerInfo, ThreadSchedulerUPP userUPP);
+	void InvokeThreadSwitchUPP (uint threadBeingSwitched, void* switchProcParam, ThreadSwitchUPP userUPP);
+	void InvokeThreadTerminationUPP (uint threadTerminated, void* terminationProcParam, ThreadTerminationUPP userUPP);
+	void InvokeDebuggerNewThreadUPP (uint threadCreated, DebuggerNewThreadUPP userUPP);
+	void InvokeDebuggerDisposeThreadUPP (uint threadDeleted, DebuggerDisposeThreadUPP userUPP);
+	uint InvokeDebuggerThreadSchedulerUPP (SchedulerInfoRecPtr schedulerInfo, DebuggerThreadSchedulerUPP userUPP);
+	short NewThread (uint threadStyle, ThreadEntryTPP threadEntry, void* threadParam, int stackSize, uint options, void** threadResult, ThreadID* threadMade);
+	short SetThreadScheduler (ThreadSchedulerTPP threadScheduler);
+	short SetThreadSwitcher (uint thread, ThreadSwitchTPP threadSwitcher, void* switchProcParam, ubyte inOrOut);
+	short SetThreadTerminator (uint thread, ThreadTerminationTPP threadTerminator, void* terminationProcParam);
+	short SetDebuggerNotificationProcs (DebuggerNewThreadTPP notifyNewThread, DebuggerDisposeThreadTPP notifyDisposeThread, DebuggerThreadSchedulerTPP notifyThreadScheduler);
+	short CreateThreadPool (uint threadStyle, short numToCreate, int stackSize);
+	short GetDefaultThreadStackSize (uint threadStyle, Size* stackSize);
+	short ThreadCurrentStackSpace (uint thread, ByteCount* freeStack);
+	short DisposeThread (uint threadToDump, void* threadResult, ubyte recycleThread);
+	short YieldToThread (uint suggestedThread);
+	short YieldToAnyThread ();
+	short GetCurrentThread (ThreadID* currentThreadID);
+	short GetThreadState (uint threadToGet, ThreadState* threadState);
+	short SetThreadState (uint threadToSet, ushort newState, uint suggestedThread);
+	short SetThreadStateEndCritical (uint threadToSet, ushort newState, uint suggestedThread);
+	short ThreadBeginCritical ();
+	short ThreadEndCritical ();
+	short GetThreadCurrentTaskRef (ThreadTaskRef* threadTRef);
+	short GetThreadStateGivenTaskRef (ThreadTaskRef threadTRef, uint threadToGet, ThreadState* threadState);
+	short SetThreadReadyGivenTaskRef (ThreadTaskRef threadTRef, uint threadToSet);
+}
\ No newline at end of file