nuget server logo nuget api documents
↑

API Docs / Microsoft.VisualBasic.Runtime / LQuerySchedule

LQuerySchedule

Full name Microsoft.VisualBasic.Parallel.Linq.LQuerySchedule Assembly Microsoft.VisualBasic.Runtime Members 9

Parallel Linq query library for VisualBasic. (用于高效率执行批量查询操作和用于检测操作超时的工具对象,请注意,为了提高查询的工作效率,请尽量避免在查询操作之中生成新的临时对象 并行版本的LINQ查询和原始的线程操作相比具有一些性能上面的局限性)

00 Remarks

在使用Parallel LINQ的时候,请务必要注意不能够使用Let语句操作共享变量,因为排除死锁的开销比较大

在设计并行任务的时候应该遵循的一些原则:

  1. 假若每一个任务之间都是相互独立的话,则才可以进行并行化调用
  2. 在当前程序域之中只能够通过线程的方式进行并行化,对于时间较短的任务而言,非并行化会比并行化更加有效率
  3. 但是对于这些短时间的任务,仍然可以将序列进行分区合并为一个大型的长时间任务来产生并行化
  4. 对于长时间的任务,可以直接使用并行化Linq拓展执行并行化

这个模块主要是针对大量的短时间的任务序列的并行化的,用户可以在这里配置线程的数量自由的控制并行化的程度

01 Syntax

Microsoft.VisualBasic.Parallel.Linq.LQuerySchedule

02 Methods

NameOverloadsSummary
AutoConfig 1 假如小于0,则认为是自动配置,0被认为是单线程,反之直接返回
LQuery 3 将大量的短时间的任务进行分区,合并,然后再执行并行化
DefaultConfig 1
LQuery 2
Where 1

03 Properties

NameOverloadsSummary
CPU_NUMBER 1 Get the number of processors on the current machine.

04 Members

method AutoConfig #
AutoConfig(Int32)

假如小于0,则认为是自动配置,0被认为是单线程,反之直接返回

Parameters
NameTypeDescription
nInt32

-

method LQuery overload 3 #
LQuery``2(IEnumerable(Of ``0), Func(Of ``0, ``1), Int32)

将大量的短时间的任务进行分区,合并,然后再执行并行化,请注意,task参数不能够使lambda表达式,否则会出现EntryNotFound的错误

Type Parameters
NameDescription
T
TOut
Parameters
NameTypeDescription
inputsIEnumerable(Of ``0)

-

taskFunc(Of ``0, ``1)

-

parTokensInt32

函数参数是每一个分区里面的元素的数量

method LQuery #
LQuery``2(IEnumerable(Of ``0), Func(Of ``0, ``1), Func(Of ``0, Boolean), Int32)

将大量的短时间的任务进行分区,合并,然后再执行并行化

Type Parameters
NameDescription
T
TOut
Parameters
NameTypeDescription
inputsIEnumerable(Of ``0)

-

taskFunc(Of ``0, ``1)

-

whereFunc(Of ``0, Boolean)

Processing where test on the inputs

method LQuery overload 2 #
LQuery``2(IEnumerable(Of ``0), Func(Of ``0, ``1), Func(Of ``1, Boolean), Int32)

将大量的短时间的任务进行分区,合并,然后再执行并行化

Type Parameters
NameDescription
T
TOut
Parameters
NameTypeDescription
inputsIEnumerable(Of ``0)

-

taskFunc(Of ``0, ``1)

-

outWhereFunc(Of ``1, Boolean)

Processing where test on the output

property CPU_NUMBER #
CPU_NUMBER

Get the number of processors on the current machine.

Remarks

(获取当前的系统主机的CPU核心数)

Returns

A reference to the Environment.ProcessorCount

method DefaultConfig #
DefaultConfig()
method LQuery overload 2 #
LQuery(IEnumerable(Of T), Func(Of T, TOut), Int32)
method LQuery #
LQuery(IEnumerable(Of T), Func(Of T, TOut), Func(Of T, Boolean), Int32)
method Where #
Where(IEnumerable(Of T), Func(Of T, Boolean), Int32)