设置首页收藏本站
开启左侧

How to make multithreading call and get output results from threads?

[复制链接]
Evgeniy 发表于 2021-7-15 19:26:31 | 显示全部楼层 |阅读模式
Hi, Colleagues!

Can you help me with one task?

I need to call some procedure 4 times and get results from each threads after execution.

Is anybody know how to make it easy?

My code now is:

Count:=(|MirrorsData|-2)/3
MirrorWidth:=MirrorsData[|MirrorsData|-2]
MirrorHeight:=MirrorsData[|MirrorsData|-1]

FullTime:=0

Threads:=[]



for Index := 0 to |MirrorsData|-3 by 3


    X:=MirrorsData[Index]
    Y:=MirrorsData[Index+1]
    Ang:=MirrorsData[Index+2]

    MirrorAreaData:=[X,Y,Ang,MirrorWidth,MirrorHeight]

    copy_image(SourceImage, DupImage)

    par_start<LabelingProcessThread.at(Index)>: Get_Label_Collerete_And_Cap (DupImage, \
                                                        LabelPartImage, \
                                                        CollereteImage, \
                                                        CapImage, \
                                                        MirrorAreaData, \
                                                        HangersData, \
                                                        MirrorAreaData, \
                                                        MirrorAreaData, \
                                                        CollereteData, \
                                                        CapData, \
                                                        HangersShapeModel, \
                                                        TimeElapsed)

endfor
convert_vector_to_tuple (LabelingProcessThread, ImageProcessingThreads)
count_seconds (T1)
par_join(ImageProcessingThreads)
count_seconds (T2)

TimePar:=1000.0*(T2-T1)

return ()




Looks like he is working. But I don't understand how to get results from threads after execution.
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| Evgeniy 发表于 2021-7-15 19:29:19 | 显示全部楼层
I need to get TimeElapsed and Images for begin :)
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
绝地武士 发表于 2021-7-15 20:58:50 | 显示全部楼层
  1. ThreadIDs := []
  2.   for Index := 1 to 5 by 1
  3.     par_start <ThreadID> : gather_data()
  4.     ThreadIDs := [ThreadIDs, ThreadID]
  5.   endfor
复制代码

  1. for Index := 1 to 5 by 1
  2.     par_start <ThreadIDs.at(Index - 1)> : gather_data()
  3.   endfor
复制代码

  1. for Index := 1 to 5 by 1
  2.     par_start <ThreadIDs.at(Index - 1)> : gather_data(Result.at(Index - 1))
  3.   endfor
复制代码
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| Evgeniy 发表于 2021-7-19 18:26:58 | 显示全部楼层
Hi, Jedi Knight!

Thank you for your answer.

I need to understand how to get results from threads after execution.

    par_start<FindDfmThread.at(Index)>: Find_Local_Dfm(ImageReduced, Threshold, FindCount, DFMs[Index], \
                               Score.at(Index), Row.at(Index), Col.at(Index))

How to get Score, Row and Col?

The results returns as Score = {[0.95 , 0.84 , 0.77 , 0.66 , 0.51 ]} and I don'tunderstand how to get this Tuple parameter.

How to use their values in cycle?
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| Evgeniy 发表于 2021-7-19 18:38:24 | 显示全部楼层
Oh, I see )))

I just need to use operator:

convert_vector_to_tuple (Score, ConvertedScores)

Ok! It is works!!!
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表