当前位置:网站首页>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
job
The mechanism starts the background process . - utilize
loop
The 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
1000W
Data , StatisticsMoeny
Total field amount
- establish
demo
The 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
name
And 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
边栏推荐
- 谈思生物直播—GENOVIS张洪妍抗体特异性酶切技术助力抗体药物结构表征
- Uniapp uses uni upgrade Center
- Interpretation of R & D effectiveness measurement framework
- 关于NAND FLASH解扣的认识
- Joint Time-Frequency and Time Domain Learning for Speech Enhancement
- Abbirb120 industrial robot mechanical zero position
- Message queue monitoring refund task batch process
- Unity xlua co process packaging
- LeetCode 454. Add four numbers II
- Onenet Internet of things platform - mqtt product devices send messages to message queues MQ
猜你喜欢
Typora realizes automatic uploading of picture pasting
Prepare for the Blue Bridge Cup Day10__ PWM control light brightness
NOV Schedule for . Net to display and organize appointments and recurring events
[classic example] classic list questions @ list
Uniapp uses uni upgrade Center
Mechanism and type of CPU context switch
Deep understanding of grpc part1
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 8
[datawhale202206] pytorch recommendation system: multi task learning esmm & MMOE
自组织是管理者和成员的双向奔赴
随机推荐
比特熊直播间一周年,英雄集结令!邀你来合影!
S7-1500plc simulation
Switch basic experiment
Onenet Internet of things platform - create mqtts products and devices
91.(cesium篇)cesium火箭发射模拟
IOS interview
STM32 project practice (1) introduction and use of photosensitive resistor
leetcode 406. Queue reconstruction by height
本科毕业四年:工作,辞职,结婚,买房
GID:旷视提出全方位的检测模型知识蒸馏 | CVPR 2021
栈的应用——括号匹配问题
Huawei HMS core joins hands with hypergraph to inject new momentum into 3D GIS
The Missing Semester
【datawhale202206】pyTorch推荐系统:多任务学习 ESMM&MMOE
How to use opcache, an optimization acceleration component of PHP
Implementation of address book management system with C language
GPS 数据中的精度因子(DOP)与协方差之间的关系 (参考链接)
[datawhale202206] pytorch recommendation system: recall model DSSM & youtubednn
Prepare for the Blue Bridge Cup Day10__ PWM control light brightness
(mixed version 1) multiple TXT text to one table