Parallel Linq query library for VisualBasic. (用于高效率执行批量查询操作和用于检测操作超时的工具对象,请注意,为了提高查询的工作效率,请尽量避免在查询操作之中生成新的临时对象 并行版本的LINQ查询和原始的线程操作相比具有一些性能上面的局限性)
LQuerySchedule
00 Remarks
在使用Parallel LINQ的时候,请务必要注意不能够使用Let语句操作共享变量,因为排除死锁的开销比较大
在设计并行任务的时候应该遵循的一些原则:
- 假若每一个任务之间都是相互独立的话,则才可以进行并行化调用
- 在当前程序域之中只能够通过线程的方式进行并行化,对于时间较短的任务而言,非并行化会比并行化更加有效率
- 但是对于这些短时间的任务,仍然可以将序列进行分区合并为一个大型的长时间任务来产生并行化
- 对于长时间的任务,可以直接使用并行化Linq拓展执行并行化
这个模块主要是针对大量的短时间的任务序列的并行化的,用户可以在这里配置线程的数量自由的控制并行化的程度
01 Syntax
Microsoft.VisualBasic.Parallel.Linq.LQuerySchedule
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| AutoConfig | 1 | 假如小于0,则认为是自动配置,0被认为是单线程,反之直接返回 |
| LQuery | 3 | 将大量的短时间的任务进行分区,合并,然后再执行并行化 |
| DefaultConfig | 1 | |
| LQuery | 2 | |
| Where | 1 |
03 Properties
| Name | Overloads | Summary |
|---|---|---|
| CPU_NUMBER | 1 | Get the number of processors on the current machine. |
04 Members
AutoConfig(
Int32)假如小于0,则认为是自动配置,0被认为是单线程,反之直接返回
Parameters
| Name | Type | Description |
|---|---|---|
n | Int32 | - |
LQuery``2(
IEnumerable(Of ``0), Func(Of ``0, ``1), Int32)将大量的短时间的任务进行分区,合并,然后再执行并行化,请注意,task参数不能够使lambda表达式,否则会出现EntryNotFound的错误
Type Parameters
| Name | Description |
|---|---|
T | |
TOut |
Parameters
| Name | Type | Description |
|---|---|---|
inputs | IEnumerable(Of ``0) | - |
task | Func(Of ``0, ``1) | - |
parTokens | Int32 | 函数参数是每一个分区里面的元素的数量 |
LQuery``2(
IEnumerable(Of ``0), Func(Of ``0, ``1), Func(Of ``0, Boolean), Int32)将大量的短时间的任务进行分区,合并,然后再执行并行化
Type Parameters
| Name | Description |
|---|---|
T | |
TOut |
Parameters
| Name | Type | Description |
|---|---|---|
inputs | IEnumerable(Of ``0) | - |
task | Func(Of ``0, ``1) | - |
where | Func(Of ``0, Boolean) | Processing where test on the inputs |
LQuery``2(
IEnumerable(Of ``0), Func(Of ``0, ``1), Func(Of ``1, Boolean), Int32)将大量的短时间的任务进行分区,合并,然后再执行并行化
Type Parameters
| Name | Description |
|---|---|
T | |
TOut |
Parameters
| Name | Type | Description |
|---|---|---|
inputs | IEnumerable(Of ``0) | - |
task | Func(Of ``0, ``1) | - |
outWhere | Func(Of ``1, Boolean) | Processing where test on the output |
CPU_NUMBER
Get the number of processors on the current machine.
Remarks
(获取当前的系统主机的CPU核心数)
Returns
A reference to the Environment.ProcessorCount
DefaultConfig()
LQuery(
IEnumerable(Of T), Func(Of T, TOut), Int32)LQuery(
IEnumerable(Of T), Func(Of T, TOut), Func(Of T, Boolean), Int32)Where(
IEnumerable(Of T), Func(Of T, Boolean), Int32)