You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A special pointer type called the ##**Any** [[KeyPgPtr|Ptr]]## (or "##**Any** [[KeyPgPtr|Pointer]]##") allows pointing to any variable type. If you cast it to a ##//[[DataType]]// [[KeyPgPtr|Ptr]]##, it can be indexed or dereferenced to access the memory as an instance of ##//[[DataType]]//##. Pointer arithmetic is allowed on an ##**Any** Ptr##, and treats it like a ##[[KeyPgByte|Byte]] Ptr##: The pointer is changed by increments of ##1##.
26
26
27
27
A pure ##**Any** [[KeyPgPtr|Ptr]]## has no type checking by the compiler. It can be implicitly converted to and from other pointer types through assignment or parameter passing.
@@ -30,27 +30,27 @@ The ##**Any**## keyword is used as a placeholder for a type or value in various
30
30
31
31
This should not be confused with ##**Variant**##, a Visual Basic data type which can contain any type of variable. ""FreeBASIC"" does not provide native support for a ##**Variant**## type.
32
32
33
-
- Byref parameters:
33
+
- Byref parameters (2nd syntax):
34
34
**##Any##** can be used in procedure prototypes (in a ##[[KeyPgDeclare|Declare]]## statement) with ##[[KeyPgByref|ByRef]]## parameters to disable the compiler checking for the correct type of the variable passed (this includes the array parameters because always implicitly passed by reference).
35
35
However, it does not work with UDT member procedures, except if they are static procedures.
36
36
This use of ##**Any**## is deprecated and it only exists for compatibility with QB.
37
37
38
-
- Array dimensions:
38
+
- Array dimensions (3rd/4th syntax):
39
39
In array declarations, **##Any##** can be specified in place of the array bounds in order to create a dynamic array with a certain amount of dimensions that is determined based on the number of **##Any##**s specified (use the syntax with **##Any##** is mandatory when declaring a dynamic array member inside a ##[[KeyPgType|Type]]##).
40
40
41
41
In parameter declarations, **##Any##** can be also specified instead of empty parenthesis in order to fix the amount of dimensions.
42
42
43
-
- Initialization:
43
+
- Initialization (5th/6th/7th syntax):
44
44
##**Any**## can be used as a fake initializer to disable the default initialization of variables to ##0##, leaving the variable uninitialized. This may save time in critical sections of a program. It is the program's responsibility to fill the variables with meaningful data before reading it.
45
45
46
46
Comparison to ""C/C++"": This matches the behavior of a variable declaration without initialization value in ""C/C++"".
47
47
48
48
Similar to **##Any##** initializers for variables, **##Any##** can also be used with the ##[[KeyPgOpNew|New Expression]]## or ##[[KeyPgOpPlacementNew|Placement New]]## operators in order to leave the newly created object uninitialized (only allowed with data types that do not have constructors).
49
49
50
-
- ""Instr/InstrRev"":
50
+
- ""Instr/InstrRev"" (8th syntax):
51
51
**##Any##** can be used with ##[[KeyPgInstr|Instr]]## or ##[[KeyPgInstrrev|InstrRev]]## as a qualifier for the ##//substring//## parameter, to indicate that any individual character in it may be matched.
52
52
53
-
- Procptr:
53
+
- Procptr (9th syntax):
54
54
**##Any##**, ie any procedure signature, does not induce any particular selection (compared to its non-use), but just allows for writing ##[[KeyPgOpProcptr|Procptr]]## always with 2 arguments.
Dim As Function(ByVal p As Any Ptr) As String _pThread
309
309
Dim As Any Ptr _p
@@ -557,7 +557,7 @@ Second user function executed like a thread function:
557
557
**""-""** A second sequence (b) of 3 ""'PoolingSubmit'"" is requested for the last three user thread functions, ended by a ""'PoolingWait'"" with a dynamic string array as argument (so, only the returns from the last three user thread functions will fill out in the dynamic string array).
**""-""** For ""'ThreadDispatching'"": 32 sub-tasks are always used and the distribution of these sub-tasks over the available threads (max = 1/2/4/8/16/32) is automatic.
1204
1204
1205
1205
Full code with the ""'ThreadInitThenMultiStart'"", ""'ThreadPooling'"", and ""'ThreadDispatching'"" Types:
Dim As Function(ByVal p As Any Ptr) As String _pThread
1209
1209
Dim As Any Ptr _p
@@ -1768,7 +1768,7 @@ Sleep
1768
1768
The objective of thread pooling (""ThreadInitThenMultiStart"", ""ThreadPooling"", ""ThreadDispatching"" methods) is to pool threads in order to avoid the untimely creation or deletion of threads, and thus allow their reuse.
1769
1769
1770
1770
Test code to evaluate the different times wasted depending on the feature used:
Copy file name to clipboardExpand all lines: doc/manual/cache/ProPgMtCriticalSectionsFAQ.wakka
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1582,7 +1582,7 @@ Sub threadUDT.condDestroy ()
1582
1582
End Sub
1583
1583
%%
1584
1584
- From the example 2 on the ##[[ProPgMtCriticalSections|Critical Sections]]## page "Synchronous method example using a condwait then a condbroadcast (and a mutex) for all threads", now the user implementation is modified to be compatible with the base Class 'threadUDT':
After a while of observation, one can find both small negative values and large positive values.
1781
1781
1782
1782
Interesting to see the min time, average time, and max time, between the executing start of thread body and the returning point of ""'ThreadCreate()'"":
0 commit comments