Przeglądaj źródła

Fixed for threaded build. Changed to SuperStrict.

woollybah 11 lat temu
rodzic
commit
e34341d5ee
2 zmienionych plików z 28 dodań i 26 usunięć
  1. 26 26
      threads.mod/threads.bmx
  2. 2 0
      threads.mod/threads.x

+ 26 - 26
threads.mod/threads.bmx

@@ -1,5 +1,5 @@
 
 
-Strict
+SuperStrict
 
 
 Rem
 Rem
 bbdoc: System/Threads 
 bbdoc: System/Threads 
@@ -23,12 +23,12 @@ Private
 
 
 Extern
 Extern
 
 
-Function bbThreadAllocData:Byte Ptr()
-Function bbThreadSetData( index,data:Object )
-Function bbThreadGetData:Object( index )
+Function bbThreadAllocData:Int()
+Function bbThreadSetData( index:Int,data:Object )
+Function bbThreadGetData:Object( index:Int )
 
 
-Function bbAtomicCAS( target Var,old_value,new_value )
-Function bbAtomicAdd( target Var,value )
+Function bbAtomicCAS:Int( target:Int Var,old_value:Int,new_value:Int )
+Function bbAtomicAdd:Int( target:Int Var,value:Int )
 
 
 Function threads_CreateThread:Byte Ptr( entry:Object( data:Object ),data:Object )
 Function threads_CreateThread:Byte Ptr( entry:Object( data:Object ),data:Object )
 Function threads_DetachThread( thread:Byte Ptr )
 Function threads_DetachThread( thread:Byte Ptr )
@@ -37,10 +37,10 @@ Function threads_WaitThread:Object( thread:Byte Ptr )
 Function threads_CreateMutex:Byte Ptr()
 Function threads_CreateMutex:Byte Ptr()
 Function threads_CloseMutex( mutex:Byte Ptr )
 Function threads_CloseMutex( mutex:Byte Ptr )
 Function threads_LockMutex( mutex:Byte Ptr )
 Function threads_LockMutex( mutex:Byte Ptr )
-Function threads_TryLockMutex( mutex:Byte Ptr )
+Function threads_TryLockMutex:Int( mutex:Byte Ptr )
 Function threads_UnlockMutex( mutex:Byte Ptr )
 Function threads_UnlockMutex( mutex:Byte Ptr )
 
 
-Function threads_CreateSemaphore:Byte Ptr( count )
+Function threads_CreateSemaphore:Byte Ptr( count:Int )
 Function threads_CloseSemaphore( sema:Byte Ptr )
 Function threads_CloseSemaphore( sema:Byte Ptr )
 Function threads_WaitSemaphore( sema:Byte Ptr )
 Function threads_WaitSemaphore( sema:Byte Ptr )
 Function threads_PostSemaphore( sema:Byte Ptr )
 Function threads_PostSemaphore( sema:Byte Ptr )
@@ -89,7 +89,7 @@ Type TThread
 	Rem
 	Rem
 	bbdoc: Check if this thread is running
 	bbdoc: Check if this thread is running
 	End Rem
 	End Rem
-	Method Running()
+	Method Running:Int()
 		Return _running
 		Return _running
 	End Method
 	End Method
 	
 	
@@ -132,7 +132,7 @@ Type TThread
 		If _handle threads_DetachThread _handle
 		If _handle threads_DetachThread _handle
 	End Method
 	End Method
 	
 	
-	Field _running
+	Field _running:Int
 	Field _handle:Byte Ptr
 	Field _handle:Byte Ptr
 	Field _result:Object
 	Field _result:Object
 	
 	
@@ -164,14 +164,14 @@ Type TThreadData
 	bbdoc: Create thread data
 	bbdoc: Create thread data
 	End Rem
 	End Rem
 	Function Create:TThreadData()
 	Function Create:TThreadData()
-		Local handle:Byte Ptr=bbThreadAllocData()
-		If Not handle Return
+		Local handle:Int=bbThreadAllocData()
+		If Not handle Return Null
 		Local data:TThreadData=New TThreadData
 		Local data:TThreadData=New TThreadData
 		data._handle=handle
 		data._handle=handle
 		Return data
 		Return data
 	End Function
 	End Function
 
 
-	Field _handle:Byte Ptr
+	Field _handle:Int
 
 
 End Type
 End Type
 
 
@@ -201,7 +201,7 @@ Type TMutex
 	bbdoc: Try to lock the mutex
 	bbdoc: Try to lock the mutex
 	returns: #True if mutex was successfully locked; #False if mutex was already locked by another thread.
 	returns: #True if mutex was successfully locked; #False if mutex was already locked by another thread.
 	End Rem
 	End Rem
-	Method TryLock()
+	Method TryLock:Int()
 		Assert _handle
 		Assert _handle
 		Return threads_TryLockMutex( _handle )
 		Return threads_TryLockMutex( _handle )
 	End Method
 	End Method
@@ -219,7 +219,7 @@ Type TMutex
 	End Rem
 	End Rem
 	Function Create:TMutex()
 	Function Create:TMutex()
 		Local handle:Byte Ptr=threads_CreateMutex()
 		Local handle:Byte Ptr=threads_CreateMutex()
-		If Not handle Return
+		If Not handle Return Null
 		Local mutex:TMutex=New TMutex
 		Local mutex:TMutex=New TMutex
 		mutex._handle=handle
 		mutex._handle=handle
 		Return mutex
 		Return mutex
@@ -266,9 +266,9 @@ Type TSemaphore
 	Rem
 	Rem
 	bbdoc: Create a new semaphore
 	bbdoc: Create a new semaphore
 	End Rem
 	End Rem
-	Function Create:TSemaphore( count )
+	Function Create:TSemaphore( count:Int )
 		Local handle:Byte Ptr=threads_CreateSemaphore( count )
 		Local handle:Byte Ptr=threads_CreateSemaphore( count )
-		If Not handle Return
+		If Not handle Return Null
 		Local semaphore:TSemaphore=New TSemaphore
 		Local semaphore:TSemaphore=New TSemaphore
 		semaphore._handle=handle
 		semaphore._handle=handle
 		Return semaphore
 		Return semaphore
@@ -325,7 +325,7 @@ Type TCondVar
 	End Rem
 	End Rem
 	Function Create:TCondVar()
 	Function Create:TCondVar()
 		Local handle:Byte Ptr=threads_CreateCond()
 		Local handle:Byte Ptr=threads_CreateCond()
-		If Not handle Return
+		If Not handle Return Null
 		Local condvar:TCondVar=New TCondVar
 		Local condvar:TCondVar=New TCondVar
 		condvar._handle=handle
 		condvar._handle=handle
 		Return condvar
 		Return condvar
@@ -382,7 +382,7 @@ Once one a thread has been detached, it wil no longer be possible to use #WaitTh
 This allows the thread to run without your program having to continually check whether it has completedin order to close it.
 This allows the thread to run without your program having to continually check whether it has completedin order to close it.
 End Rem
 End Rem
 Function DetachThread( thread:TThread )
 Function DetachThread( thread:TThread )
-	Return thread.Detach()
+	thread.Detach()
 End Function
 End Function
 
 
 Rem
 Rem
@@ -403,7 +403,7 @@ Rem
 bbdoc: Check if a thread is running
 bbdoc: Check if a thread is running
 returns: #True if @thread is still running, otherwise #False.
 returns: #True if @thread is still running, otherwise #False.
 End Rem
 End Rem
-Function ThreadRunning( thread:TThread )
+Function ThreadRunning:Int( thread:TThread )
 	Return thread.Running()
 	Return thread.Running()
 End Function
 End Function
 
 
@@ -455,7 +455,7 @@ Rem
 bbdoc: Try to lock a mutex
 bbdoc: Try to lock a mutex
 returns: #True if @mutex was successfully locked; #False if @mutex was already locked by another thread.
 returns: #True if @mutex was successfully locked; #False if @mutex was already locked by another thread.
 End Rem
 End Rem
-Function TryLockMutex( mutex:TMutex )
+Function TryLockMutex:Int( mutex:TMutex )
 	Return mutex.TryLock()
 	Return mutex.TryLock()
 End Function
 End Function
 
 
@@ -470,7 +470,7 @@ Rem
 bbdoc: Create a semaphore
 bbdoc: Create a semaphore
 returns: A new semaphore object
 returns: A new semaphore object
 End Rem
 End Rem
-Function CreateSemaphore:TSemaphore( count )
+Function CreateSemaphore:TSemaphore( count:Int )
 	Return TSemaphore.Create( count )
 	Return TSemaphore.Create( count )
 End Function
 End Function
 
 
@@ -537,7 +537,7 @@ returns: @True if target was updated
 about:
 about:
 Atomically replace @target with @new_value if @target equals @old_value.
 Atomically replace @target with @new_value if @target equals @old_value.
 End Rem
 End Rem
-Function CompareAndSwap( target Var,oldValue,newValue )
+Function CompareAndSwap:Int( target:Int Var,oldValue:Int,newValue:Int )
 	Return bbAtomicCAS( target,oldValue,newValue )
 	Return bbAtomicCAS( target,oldValue,newValue )
 End Function
 End Function
 
 
@@ -547,7 +547,7 @@ returns: Previuous value of target
 about:
 about:
 Atomically add @value to @target.
 Atomically add @value to @target.
 End Rem
 End Rem
-Function AtomicAdd( target Var,value )
+Function AtomicAdd:Int( target:Int Var,value:Int )
 	Return bbAtomicAdd( target,value )
 	Return bbAtomicAdd( target,value )
 End Function
 End Function
 
 
@@ -555,9 +555,9 @@ Rem
 bbdoc: Atomically swap values
 bbdoc: Atomically swap values
 returns: The old value of @target
 returns: The old value of @target
 End Rem
 End Rem
-Function AtomicSwap( target Var,value )
+Function AtomicSwap:Int( target:Int Var,value:Int )
 	Repeat
 	Repeat
-		Local oldval=target
+		Local oldval:Int=target
 		If CompareAndSwap( target,oldval,value ) Return oldval
 		If CompareAndSwap( target,oldval,value ) Return oldval
 	Forever
 	Forever
 End Function
 End Function

+ 2 - 0
threads.mod/threads.x

@@ -0,0 +1,2 @@
+int bbAtomicAdd( int *,int )!
+int bbAtomicCAS( int *,int ,int )!