Revision history for KeyPgMutexDestroy


Revision [20986]

Last edited on 2016-03-13 04:48:41 by fxm [Formatting]
Additions:

See ##[[KeyPgMutexCreate|Mutexcreate]]## for more general information on mutexes.
Deletions:
See ##[[KeyPgMutexCreate|Mutexcreate]]## for more general information on mutexes.


Revision [20333]

Edited on 2016-02-10 16:03:09 by DkLwikki [Update link format]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgSub|sub]] **Mutexdestroy** ( [[KeyPgByval|byval]] //id// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]] )
The ##[[KeyPgAny|any]] [[KeyPgPtr|ptr]]## handle of the mutex to be destroyed.
##Mutexdestroy## discards a mutex created by ##[[KeyPgMutexCreate|Mutexcreate]]##. This call should be executed after any threads using the mutex are no longer in use.
See ##[[KeyPgMutexCreate|Mutexcreate]]## for more general information on mutexes.
See the examples in ##[[KeyPgMutexCreate|Mutexcreate]]## and also ##[[KeyPgThreadCreate|Threadcreate]]##.
- Threading is not allowed in the //[[CompilerOptlang|-lang qb]]// dialect.
- ##[[KeyPgMutexCreate|Mutexcreate]]##
- ##[[KeyPgMutexLock|Mutexlock]]##
- ##[[KeyPgMutexUnlock|Mutexunlock]]##
- ##[[KeyPgThreadCreate|Threadcreate]]##
- ##[[KeyPgThreadWait|Threadwait]]##
Deletions:
[[KeyPgDeclare declare]] [[KeyPgSub sub]] **Mutexdestroy** ( [[KeyPgByval byval]] //id// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] )
The ##[[KeyPgAny any]] [[KeyPgPtr ptr]]## handle of the mutex to be destroyed.
##Mutexdestroy## discards a mutex created by ##[[KeyPgMutexCreate Mutexcreate]]##. This call should be executed after any threads using the mutex are no longer in use.
See ##[[KeyPgMutexCreate Mutexcreate]]## for more general information on mutexes.
See the examples in ##[[KeyPgMutexCreate Mutexcreate]]## and also ##[[KeyPgThreadCreate Threadcreate]]##.
- Threading is not allowed in the //[[CompilerOptlang -lang qb]]// dialect.
- ##[[KeyPgMutexCreate Mutexcreate]]##
- ##[[KeyPgMutexLock Mutexlock]]##
- ##[[KeyPgMutexUnlock Mutexunlock]]##
- ##[[KeyPgThreadCreate Threadcreate]]##
- ##[[KeyPgThreadWait Threadwait]]##


Revision [16964]

Edited on 2013-09-30 05:48:41 by FxMwikki [Added link to the Mutexcreate example]
Additions:
See the examples in ##[[KeyPgMutexCreate Mutexcreate]]## and also ##[[KeyPgThreadCreate Threadcreate]]##.
Deletions:
See the ##[[KeyPgThreadCreate Threadcreate]]## examples.


Revision [15301]

Edited on 2011-10-01 07:12:45 by DkLwikki [Point to KeyPgThreadCreate instead of duplicating]
Additions:
See the ##[[KeyPgThreadCreate Threadcreate]]## examples.
Deletions:
See the [[KeyPgThreadCreate Threadcreate]] examples.


Revision [15294]

Edited on 2011-10-01 07:09:13 by DkLwikki [Point to KeyPgThreadCreate instead of duplicating]
Additions:
- The DOS version of ""FreeBASIC"" does not allow for threads, as the OS does not support them.
- In Linux the threads are always started in the order they are created, this can't be assumed in ""Win32"". It's an OS, not a ""FreeBASIC"" issue.
Deletions:
- The DOS version of FreeBASIC does not allow for threads, as the OS does not support them.
- In Linux the threads are always started in the order they are created, this can't be assumed in Win32. It's an OS, not a FreeBASIC issue.


Revision [15289]

Edited on 2011-10-01 07:06:42 by DkLwikki [Point to KeyPgThreadCreate instead of duplicating]
Additions:
See the [[KeyPgThreadCreate Threadcreate]] examples.
Deletions:
{{fbdoc item="filename" value="examples/manual/threads/mutexdestroy.bas"}}%%(freebasic)
'' Threading synchronization using Mutexes
'' If you comment out the lines containing "MutexLock" and "MutexUnlock",
'' the threads will not be in sync and some of the data may be printed
'' out of place.
DECLARE SUB thread1( param as any ptr )
DECLARE SUB thread2( param as any ptr )
DECLARE SUB teletype (BYVAL text AS STRING, BYVAL x AS INTEGER, BYVAL y AS INTEGER)
DIM SHARED threadsync AS any ptr
DIM SHARED thread1handle AS any ptr
DIM SHARED thread2handle AS any ptr
'' Create a mutex to syncronize the threads
threadsync = MUTEXCREATE
'' Call thread 1
thread1handle = THREADCREATE(@thread1)
IF thread1handle = 0 THEN
PRINT "Error creating thread1"
END IF
'' Call thread 2
thread2handle = THREADCREATE(@thread2)
IF thread2handle = 0 THEN
PRINT "Error creating thread1"
END IF
'' Wait until both threads are finished
THREADWAIT(thread1handle)
THREADWAIT(thread2handle)
teletype "Testing.................", 1, 1
teletype "Testing again...........", 10, 1
'' Discard the mutex when we are through using teletype
MUTEXDESTROY threadsync
SLEEP
END
'' Thread 1 calls a simple "teletype" routine
SUB thread1( param as any ptr )
teletype "This is a test...", 4, 1
END SUB
'' ...As does thread 2
SUB thread2( param as any ptr )
teletype "This is another test...", 7, 1
END SUB
'' Teletype unfurls some text across the screen at a given location
SUB teletype (BYVAL text AS STRING, BYVAL x AS INTEGER, BYVAL y AS INTEGER)
DIM i AS INTEGER, a AS INTEGER
DIM text_length AS INTEGER
text_length = LEN(text)
FOR a = 0 TO text_length
'' MutexLock prevents the two simultaneously running
'' threads from sharing "x", "y", and "a"
MUTEXLOCK threadsync
LOCATE x,(y+a)
PRINT CHR(text[a])
'' MutexUnlock releases these variables for other use
MUTEXUNLOCK threadsync
SLEEP 25
NEXT a
END SUB
%%


Revision [14370]

Edited on 2009-08-29 21:54:51 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]
Additions:
- New to ""FreeBASIC""
Deletions:
- New to FreeBASIC


Revision [14011]

Edited on 2008-12-13 12:45:53 by LaananFisher [Updated: minor formatting]
Additions:
The ##[[KeyPgAny any]] [[KeyPgPtr ptr]]## handle of the mutex to be destroyed.
Deletions:
The ##[[KeyPgAny any]] [[KeyPgPtr ptr]]## handle of the mutex to be destroyed.


Revision [12358]

The oldest known version of this page was created on 2008-01-18 14:17:29 by JeffMarshall [Updated: minor formatting]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode