当前位置:网站首页>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
边栏推荐
- C#依赖注入(直白明了)讲解 一看就会系列
- Custom grpc plug-in
- Arm GIC (V) how arm TrustZone supports security interrupt analysis notes.
- MySQL common functions
- Ipv6-6to4 experiment
- Summary of JFrame knowledge points 2
- JS related interview questions and answers (1)
- Chen Gong: Micro service, is it still so pure?
- C summary of knowledge points 3
- GPS 数据中的精度因子(DOP)与协方差之间的关系 (参考链接)
猜你喜欢
![[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 6](/img/0e/0900e386f3baeaa506cc2c1696e22a.jpg)
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 6

Onenet Internet of things platform - mqtt product equipment upload data points

Uniapp uses uni upgrade Center

Onenet Internet of things platform - the console sends commands to mqtt product devices

Talk about biological live broadcast - genovis Zhang Hongyan antibody specific enzyme digestion technology helps to characterize the structure of antibody drugs

Huawei HMS core joins hands with hypergraph to inject new momentum into 3D GIS

循环链表--

2022-06-28-06-29

双链表有关操作

基于IMDB评论数据集的情感分析
随机推荐
MySQL data table creation
Rural guys earn from more than 2000 a month to hundreds of thousands a year. Most brick movers can walk my way ǃ
Golang introduces the implementation method of the corresponding configuration file according to the parameters
STM32 project practice (1) introduction and use of photosensitive resistor
uniapp 使用 uni-upgrade-center
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 4
消息队列之监控退款任务批处理过程
Joint Time-Frequency and Time Domain Learning for Speech Enhancement
usb peripheral 驱动 - cable connect/disconnect
Unity xlua co process packaging
本科毕业四年:工作,辞职,结婚,买房
ASTM D 3801固体塑料垂直燃烧试验
easyexcel的使用
Talk about biological live broadcast - genovis Zhang Hongyan antibody specific enzyme digestion technology helps to characterize the structure of antibody drugs
Summary of JFrame knowledge points 1
C # dependency injection (straight to the point) will be explained as soon as you see the series
CPI教程-异步接口创建及使用
How to understand the developed query statements
JS related interview questions and answers (1)
谈思生物直播—GENOVIS张洪妍抗体特异性酶切技术助力抗体药物结构表征