当前位置:网站首页>Chapter 14 signals (IV) - examples of multi process tasks
Chapter 14 signals (IV) - examples of multi process tasks
2022-07-01 12:21:00 【yaoxin521123】
List of articles
Chapter 14 The signal ( Four )- Multi process task example
According to this idea, multi task start-up query and summary data can be carried out .
principle
- utilize
jobThe mechanism starts the background process . - utilize
loopThe number of cycle reducing processes is equal to the number of open processes , Determine whether the multi process task is completed .
- Create a table and insert
1000WData , StatisticsMoenyTotal field amount

- establish
demoThe code is as follows .
Class Demo.SemaphoreDemo Extends %RegisteredObject
{
/// Do ##class(Demo.SemaphoreDemo).Sample(5)
ClassMethod Sample(pJobCount = 3)
{
k ^yx("Amt"),^yxAmt
/* 1. Start signal */
s mSem = ##class(Demo.Sem).%New()
If ('($isobject(mSem)))
{
q " Boot failure "
}
/* 2. The initialization semaphore is 0 */
d mSem.Init(0)
s t1 = $zh
/* 3. By specified quantity , Start background tasks */
for i = 1 : 1 : pJobCount
{
j ..Task(i)
}
w " start-up job Time :"_ ($zh - t1),!
/* 4. Wait for the background task to complete */
s tCount = i,tSC = 0
/* The judgment condition for the completion of background tasks is : Reduced semaphore = Total background tasks */
while (tSC < tCount)
{
s tSC = tSC + mSem.Decrement(tCount, 10)
}
w " Completion time :"_ ($zh - t1),!
s moneyAmt = 0
s data = ""
for {
s data = $o(^yxAmt(data))
q:(data = "")
s moneyAmt = moneyAmt + ^yxAmt(data)
}
d mSem.Delete()
w " Total sum " _ moneyAmt,!
w " Summary time :"_ ($zh - t1),!
q
}
ClassMethod Task(i)
{
s tSem = ##class(Demo.Sem).%New()
s moneyAmt = 0
for j = (i * 100000) + 1 : 1 : (i + 1) * 100000 {
s money = $li(^M.YxPersonD(j), 3)
s moneyAmt = moneyAmt + money
}
s ^yxAmt("moneyAmt" _ i) = moneyAmt
s ^yx("Amt") = $i(^yx("Amt"))
d tSem.Open(##class(Demo.Sem).Name())
d tSem.Increment(1)
d tSem.%Close()
q moneyAmt
}
}
- Create a signal class , Definition
nameAnd initialization signal method .
Class Demo.Sem Extends %SYSTEM.Semaphore
{
ClassMethod Name() As %String
{
q "Semaphore"
}
Method Init(initvalue = 0) As %Status
{
try {
If (..Create(..Name(), initvalue)) {
ret 1
} else {
ret 0
}
} catch {
ret 0
}
}
}
- call
DHC-APP>Do ##class(Demo.SemaphoreDemo).Sample(5)
start-up job Time :.098982
Completion time :.119744
Total sum 250088825096472
Summary time :.119774
边栏推荐
- What are the PHP FPM configuration parameters
- STM32 project practice (1) introduction and use of photosensitive resistor
- C summary of knowledge points 3
- How to understand the developed query statements
- 【datawhale202206】pyTorch推荐系统:召回模型 DSSM&YoutubeDNN
- 【datawhale202206】pyTorch推荐系统:多任务学习 ESMM&MMOE
- 91. (cesium chapter) cesium rocket launch simulation
- MQ-防止消息丢失及重复消费
- [datawhale202206] pytorch recommendation system: multi task learning esmm & MMOE
- 【datawhale202206】pyTorch推荐系统:精排模型 DeepFM&DIN
猜你喜欢

Self organization is the two-way rush of managers and members

MySQL common functions

BIM and safety in road maintenance-buildSmart Spain

Emotion analysis based on IMDB comment data set

Computer graduation project asp Net hotel room management system VS development SQLSERVER database web structure c programming computer web page source code project

Dlhsoft Kanban, Kanban component of WPF
![[106] 360 check font - check whether the copyright of local Fonts is commercially available](/img/a7/615e8000647b56f03a6a1d3dd81b6d.jpg)
[106] 360 check font - check whether the copyright of local Fonts is commercially available

【语音信号处理】3语音信号可视化——prosody

On recursion and Fibonacci sequence

被锡膏坑了一把
随机推荐
[106] 360 check font - check whether the copyright of local Fonts is commercially available
leetcode 406. Queue reconstruction by height
JS related interview questions and answers (1)
Acly and metabolic diseases
Building external modules
Why does the JVM heap memory exceed 32g and pointer compression fail?
Deep understanding of grpc part1
Huawei HMS core joins hands with hypergraph to inject new momentum into 3D GIS
GID:旷视提出全方位的检测模型知识蒸馏 | CVPR 2021
2022-06-28-06-29
Typora realizes automatic uploading of picture pasting
Golang introduces the implementation method of the corresponding configuration file according to the parameters
What are the PHP FPM configuration parameters
巩固-C#运算符
Build yocto system offline for i.mx8mmini development board
【20211129】Jupyter Notebook远程服务器配置
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 6
Machine learning - Data Science Library Day 3 - Notes
Computer graduation project asp Net attendance management system vs developing SQLSERVER database web structure c programming computer web page source code project
【datawhale202206】pyTorch推荐系统:精排模型 DeepFM&DIN