Posts: 769
Threads: 263
Joined: Jul 2012
Is it possible to create a SharedMemory trigger that also works both in QM and in exe?
I do not know how to approach this if it is possible.
The way I would try to approach this, is by using 'rep' and then repeatedly execute:
__SharedMemory sm2
lpstr m=sm2.Open("...
But I assume this is not the most effective (system resource friendly) way.
Related topics:
http://www.quickmacros.com/forum/showthr...p?tid=5686
http://www.quickmacros.com/forum/showthr...p?tid=5128
Posts: 12,097
Threads: 142
Joined: Dec 2002
05-21-2018, 09:01 PM
(This post was last modified: 05-21-2018, 09:16 PM by Gintaras.)
Open() is slow, but once opened, reading a byte or int from shared memory is as fast as reading any variable.
process 2:
__SharedMemory sm2
lpstr m=sm2.Open("...
rep
,if(m[0]=1) m[0]=0; out "trigger"
,0.05
process 1:
__SharedMemory sm2
lpstr m=sm2.Create("...
...
m[0]=1
Posts: 12,097
Threads: 142
Joined: Dec 2002
To avoid rep, use event.
Function
sm_process1
;/exe
__SharedMemory sm2
byte* m=sm2.Create("sm_82569" 1000)
__Handle ev1=CreateEvent(0 0 0 "ev1_82569")
__Handle ev2=CreateEvent(0 0 0 "ev2_82569")
int* p=m
for _i 0 10
,1
,p[0]=_i
,SetEvent ev1
SetEvent ev2
out "sm_process1 ended"
;BEGIN PROJECT
;main_function sm_process1
;exe_file $my qm$\sm_process1.qmm
;flags 6
;guid {5EF00E1E-5835-41AF-86CA-1777B56049EC}
;END PROJECT
Function
sm_process2
;/exe
__SharedMemory sm2
byte* m=sm2.Create("sm_82569" 1000)
__Handle ev1=CreateEvent(0 0 0 "ev1_82569")
__Handle ev2=CreateEvent(0 0 0 "ev2_82569")
rep
,sel wait(0 HM ev1 ev2)
,,case 1
,,int* p=m
,,out p[0]
,,
,,case 2
,,break
out "sm_process2 ended"
;BEGIN PROJECT
;main_function sm_process2
;exe_file $my qm$\sm_process2.qmm
;flags 6
;guid {473089D6-9493-4D5D-8351-736A645793E4}
;END PROJECT
To test, run sm_process2 first, then sm_process1.
Posts: 769
Threads: 263
Joined: Jul 2012