Revision history for KeyPgThreadCall


Revision [22029]

Last edited on 2017-11-27 03:55:28 by fxm [Fixed the list of unsupported subroutines]
Additions:
- Subroutines using [[KeyPgVaArg|variable arguments]].
- Subroutines with unions which are passed as arguments.
- Subroutines with user types containing unions, arrays, strings, or bitfields which are passed as arguments.
Deletions:
- Subroutines using [[KeyPgVaArg|variable arguments]]
- Subroutines with unions which are passed ##[[KeyPgByval|Byval]]##
- Subroutines with user types containing unions, arrays, strings, or bitfields which are passed ##[[KeyPgByval|Byval]]##


Revision [22016]

Edited on 2017-11-21 01:11:50 by JeffMarshall [fix page link name case]
Additions:
- Subroutines with unions which are passed ##[[KeyPgByval|Byval]]##
- Subroutines with user types containing unions, arrays, strings, or bitfields which are passed ##[[KeyPgByval|Byval]]##
- In Linux, the ##[[KeyPgStdcall|Stdcall]]## and ##[[KeyPgPascal|Pascal]]## calling conventions are not supported
Deletions:
- Subroutines with unions which are passed ##[[KeyPgByVal|Byval]]##
- Subroutines with user types containing unions, arrays, strings, or bitfields which are passed ##[[KeyPgByVal|Byval]]##
- In Linux, the ##[[KeyPgStdCall|Stdcall]]## and ##[[KeyPgPascal|Pascal]]## calling conventions are not supported


Revision [21824]

Edited on 2017-08-17 12:38:21 by fxm [Typo : guarentee -> guarantee]
Additions:
WARNING: //Presently when **Threadcall** involves to pass parameters to the thread, there is no guarantee that the corresponding data are still maintained after the end of the **Threadcall** statement and this until the thread is launched. That can cause bad behavior.//
Deletions:
WARNING: //Presently when **Threadcall** involves to pass parameters to the thread, there is no guarentee that the corresponding data are still maintained after the end of the **Threadcall** statement and this until the thread is launched. That can cause bad behavior.//


Revision [21155]

Edited on 2016-03-13 11:18:24 by fxm [Formatting]

No Differences

Revision [21154]

Edited on 2016-03-13 11:16:15 by fxm [Formatting]
Additions:





Revision [20549]

Edited on 2016-02-10 16:09:26 by DkLwikki [Update link format]
Additions:
~&//**Threadcall** uses [[ExtLibFfi|LibFFI]] internally: people who write programs using this functionality should be careful to follow ""LibFFI""'s license, which can be found at [[http://github.com/atgreen/libffi/blob/master/LICENSE]].//
[[KeyPgFunction|function]] **Threadcall** //subname//([//paramlist//]) [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]]
**Threadcall** returns an ##[[KeyPgAny|any]] [[KeyPgPtr|ptr]]## handle to the thread created, or the null pointer (##0##) on failure.
Like ##[[KeyPgThreadCreate|Threadcreate]]##, **Threadcall** creates a thread which runs at the same time as the code calling it. By placing "**Threadcall**" before almost any normal call to sub, the sub is called inside of a new thread and returns a pointer to that thread.
Using **Threadcall** is simpler method of creating threads, and allows data to be passed to the thread without global variables or pointers which are not type safe. However, ##[[KeyPgThreadCreate|Threadcreate]]## is more efficient and should be used for programs creating a large number of threads.
- Subroutines using [[KeyPgVaArg|variable arguments]]
- Subroutines with unions which are passed ##[[KeyPgByVal|Byval]]##
- Subroutines with user types containing unions, arrays, strings, or bitfields which are passed ##[[KeyPgByVal|Byval]]##
- Threading is not allowed in the //[[CompilerOptlang|-lang qb]]// dialect.
- In Linux, the ##[[KeyPgStdCall|Stdcall]]## and ##[[KeyPgPascal|Pascal]]## calling conventions are not supported
- In Windows, the ##[[KeyPgPascal|Pascal]]## calling convention is not supported.
- ##[[KeyPgThreadCreate|Threadcreate]]##
- ##[[KeyPgThreadWait|Threadwait]]##
- ##[[KeyPgMutexCreate|Mutexcreate]]##
- ##[[KeyPgMutexLock|Mutexlock]]##
- ##[[KeyPgMutexUnlock|Mutexunlock]]##
- ##[[KeyPgMutexDestroy|Mutexdestroy]]##
Deletions:
~&//**Threadcall** uses [[ExtLibFfi LibFFI]] internally: people who write programs using this functionality should be careful to follow ""LibFFI""'s license, which can be found at [[http://github.com/atgreen/libffi/blob/master/LICENSE]].//
[[KeyPgFunction function]] **Threadcall** //subname//([//paramlist//]) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
**Threadcall** returns an ##[[KeyPgAny any]] [[KeyPgPtr ptr]]## handle to the thread created, or the null pointer (##0##) on failure.
Like ##[[KeyPgThreadCreate Threadcreate]]##, **Threadcall** creates a thread which runs at the same time as the code calling it. By placing "**Threadcall**" before almost any normal call to sub, the sub is called inside of a new thread and returns a pointer to that thread.
Using **Threadcall** is simpler method of creating threads, and allows data to be passed to the thread without global variables or pointers which are not type safe. However, ##[[KeyPgThreadCreate Threadcreate]]## is more efficient and should be used for programs creating a large number of threads.
- Subroutines using [[KeyPgVaArg variable arguments]]
- Subroutines with unions which are passed ##[[KeyPgByVal Byval]]##
- Subroutines with user types containing unions, arrays, strings, or bitfields which are passed ##[[KeyPgByVal Byval]]##
- Threading is not allowed in the //[[CompilerOptlang -lang qb]]// dialect.
- In Linux, the ##[[KeyPgStdCall Stdcall]]## and ##[[KeyPgPascal Pascal]]## calling conventions are not supported
- In Windows, the ##[[KeyPgPascal Pascal]]## calling convention is not supported.
- ##[[KeyPgThreadCreate Threadcreate]]##
- ##[[KeyPgThreadWait Threadwait]]##
- ##[[KeyPgMutexCreate Mutexcreate]]##
- ##[[KeyPgMutexLock Mutexlock]]##
- ##[[KeyPgMutexUnlock Mutexunlock]]##
- ##[[KeyPgMutexDestroy Mutexdestroy]]##


Revision [17441]

Edited on 2015-02-15 03:18:59 by FxMwikki [Generalized the warning sentence about any type of passed parameter]
Additions:
WARNING: //Presently when **Threadcall** involves to pass parameters to the thread, there is no guarentee that the corresponding data are still maintained after the end of the **Threadcall** statement and this until the thread is launched. That can cause bad behavior.//
Deletions:
WARNING: //Presently when **Threadcall** involves to copy variables or objects for the thread, there is no guarentee that the copy is preserved (after the end of the **Threadcall** statement) until the thread is launched. That can cause bad behavior.//


Revision [17440]

Edited on 2015-02-14 15:17:22 by FxMwikki [Added warning about the present design]
Additions:
WARNING: //Presently when **Threadcall** involves to copy variables or objects for the thread, there is no guarentee that the copy is preserved (after the end of the **Threadcall** statement) until the thread is launched. That can cause bad behavior.//


Revision [15713]

Edited on 2012-01-16 12:14:44 by CountingPine [Added warning about the present design]
Additions:
~&//**Threadcall** uses [[ExtLibFfi LibFFI]] internally: people who write programs using this functionality should be careful to follow ""LibFFI""'s license, which can be found at [[http://github.com/atgreen/libffi/blob/master/LICENSE]].//
Deletions:
~&//**Threadcall** uses [[ExtLibFfi LibFFI]] internally: people who write programs using functionality should be careful to follow ""LibFFI""'s license, which can be found at [[http://github.com/atgreen/libffi/blob/master/LICENSE]].//


Revision [15712]

Edited on 2012-01-16 12:14:27 by CountingPine [Mention LibFFI license]
Additions:
~&//**Threadcall** uses [[ExtLibFfi LibFFI]] internally: people who write programs using functionality should be careful to follow ""LibFFI""'s license, which can be found at [[http://github.com/atgreen/libffi/blob/master/LICENSE]].//
Print "thread " & id;
Deletions:
Print "thread "; id;


Revision [15613]

Edited on 2012-01-05 12:57:00 by DkLwikki [Fix example]
Additions:
Sub thread( id As String, tlock As Any Ptr, count As Integer )
For i As Integer = 1 To count
MutexLock tlock
Print "thread "; id;
Locate , 20
Print i & "/" & count
MutexUnlock tlock
Next
Dim a As Any Ptr = ThreadCall thread("A", tlock, 6)
Dim b As Any Ptr = ThreadCall thread("B", tlock, 4)
Deletions:
Sub thread( id As String, tlock As Any Ptr )
For i As Integer = 1 to 10
MutexLock tlock
Print "Loop"; id; "is on iteration"; i
MutexUnlock tlock
Next i
Dim a As Any Ptr = ThreadCall thread("A", tlock)
Dim b As Any Ptr = ThreadCall thread("B", tlock)


Revision [15611]

Edited on 2012-01-05 07:05:39 by FxMwikki [Minor: Threadcreate -> Threadcall (in Platform Differences)]
Additions:
- **Threadcall** is not available with the DOS version / target of ""FreeBASIC"", because multithreading is not supported by DOS kernel nor the used extender.
Deletions:
- **Threadcreate** is not available with the DOS version / target of ""FreeBASIC"", because multithreading is not supported by DOS kernel nor the used extender.


Revision [15575]

Edited on 2011-12-20 21:28:50 by JoFers [Fixing a typo in the example.]
Additions:
Print "All done (and without Dim Shared!)"
Deletions:
Print "All done (and without Dim Shared!")


Revision [15570]

Edited on 2011-12-17 15:03:11 by CountingPine [Minor formatting]
Additions:
[[KeyPgFunction function]] **Threadcall** //subname//([//paramlist//]) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
//threadid// = **Threadcall** //subname//([//paramlist//])
**Threadcall** returns an ##[[KeyPgAny any]] [[KeyPgPtr ptr]]## handle to the thread created, or the null pointer (##0##) on failure.
Like ##[[KeyPgThreadCreate Threadcreate]]##, **Threadcall** creates a thread which runs at the same time as the code calling it. By placing "**Threadcall**" before almost any normal call to sub, the sub is called inside of a new thread and returns a pointer to that thread.
Using **Threadcall** is simpler method of creating threads, and allows data to be passed to the thread without global variables or pointers which are not type safe. However, ##[[KeyPgThreadCreate Threadcreate]]## is more efficient and should be used for programs creating a large number of threads.
While most subroutines are supported, the following types of subroutines may not be called:
Deletions:
Function Threadcall subname([paramlist]) as any ptr
threadid = Threadcall subname([paramlist])
**Threadcall** returns an ##[[KeyPgAny any]] [[KeyPgPtr ptr]]## handle to the thread created, or the null pointer (0) on failure.
Like ##[[KeyPgThreadCreate Threadcreate]]##, **Threadcall** creates a thread which runs at the same time as the code calling it. By placing "**Threadcall**" before almost any normal call to sub, the sub is called inside of a new thread and returns a pointer to that thread
Using **Threadcall** is simpler method of creating threads, and allows data to be passed to the thread without global variables or pointers which are not type safe. However, **Threadcreate** is more efficient and should be used for programs creating a large number of threads.
While most subroutines are supported, the following types of subroutines may not be called


Revision [15568]

Edited on 2011-12-16 21:50:45 by JoFers [Minor formatting]
Additions:
Function Threadcall subname([paramlist]) as any ptr
Deletions:
Threadcall sub([paramlist]) as any ptr


Revision [15567]

Edited on 2011-12-16 21:45:41 by JoFers [Minor formatting]
Additions:
Threadcall sub([paramlist]) as any ptr
threadid = Threadcall subname([paramlist])
##//subname//##
The name of a subroutine
##//paramlist//##
A list of parameters to pass to the subroutine, as with a normal sub call.
**Threadcall** returns an ##[[KeyPgAny any]] [[KeyPgPtr ptr]]## handle to the thread created, or the null pointer (0) on failure.
Like ##[[KeyPgThreadCreate Threadcreate]]##, **Threadcall** creates a thread which runs at the same time as the code calling it. By placing "**Threadcall**" before almost any normal call to sub, the sub is called inside of a new thread and returns a pointer to that thread
Using **Threadcall** is simpler method of creating threads, and allows data to be passed to the thread without global variables or pointers which are not type safe. However, **Threadcreate** is more efficient and should be used for programs creating a large number of threads.
While most subroutines are supported, the following types of subroutines may not be called
- Subroutines using [[KeyPgVaArg variable arguments]]
- Subroutines with unions which are passed ##[[KeyPgByVal Byval]]##
- Subroutines with user types containing unions, arrays, strings, or bitfields which are passed ##[[KeyPgByVal Byval]]##
When using **Threadcall**, parenthesis around the parameter list are required unless the subroutine has no parameters.
{{fbdoc item="filename" value="examples/manual/threads/threadcall.bas"}}%%(freebasic)
'' Threading using "ThreadCall"
Sub thread( id As String, tlock As Any Ptr )
For i As Integer = 1 to 10
MutexLock tlock
Print "Loop"; id; "is on iteration"; i
MutexUnlock tlock
Next i
End Sub
Dim tlock As Any Ptr = MutexCreate()
Dim a As Any Ptr = ThreadCall thread("A", tlock)
Dim b As Any Ptr = ThreadCall thread("B", tlock)
ThreadWait a
ThreadWait b
MutexDestroy tlock
Print "All done (and without Dim Shared!")
%%
- **Threadcreate** is not available with the DOS version / target of ""FreeBASIC"", because multithreading is not supported by DOS kernel nor the used extender.
- 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.
- In Linux, the ##[[KeyPgStdCall Stdcall]]## and ##[[KeyPgPascal Pascal]]## calling conventions are not supported
- In Windows, the ##[[KeyPgPascal Pascal]]## calling convention is not supported.
Deletions:
!!!WRITEME!!!
!!!WRITEME!!!
!!!WRITEME!!!
!!!WRITEME!!!
!!!WRITEME!!!
!!!WRITEME!!!
!!!WRITEME!!!


Revision [15554]

Edited on 2011-12-15 09:50:04 by CountingPine [Minor formatting]
Additions:
- Threading is not allowed in the //[[CompilerOptlang -lang qb]]// dialect.
Deletions:
- Threading is not allowed in ##-lang qb##


Revision [15550]

Edited on 2011-12-13 11:19:02 by host-78-144-152-38.as13285.net [Minor formatting]
Additions:
##
##


Revision [15549]

Edited on 2011-12-12 14:23:22 by CountingPine [Add section headings with !!!WRITEME!!!]
Additions:
{{fbdoc item="syntax"}}##
!!!WRITEME!!!
{{fbdoc item="usage"}}##
!!!WRITEME!!!
{{fbdoc item="param"}}
!!!WRITEME!!!
{{fbdoc item="ret"}}
!!!WRITEME!!!
{{fbdoc item="desc"}}
!!!WRITEME!!!
{{fbdoc item="ex"}}
!!!WRITEME!!!
{{fbdoc item="lang"}}
- Threading is not allowed in ##-lang qb##
{{fbdoc item="target"}}
!!!WRITEME!!!


Revision [15547]

The oldest known version of this page was created on 2011-12-12 14:18:45 by CountingPine [Add section headings with !!!WRITEME!!!]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode