Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 questions...
#8
Improved version. Previous version does not work well when the main macro started again while some old threads are still not ended. Also now is used class instead of atend.

Macro MKV
Code:
Copy      Help
out

;create list of files for testing
ARRAY(str) af; GetFilesInFolder af "q:\test"
str files=af

;==========================================================================================

__Handle+ g_sem2257; lock() if(g_sem2257=0) int nThreads=4; g_sem2257=CreateSemaphore(0 nThreads nThreads 0)
str f
foreach f files
,wait 0 H g_sem2257
,mac("sub.Convert" "" f)


#sub Convert
function $f

#compile "__SemaphoreReleaser"
SemaphoreReleaser semRel=g_sem2257

;thread code for testing
MES m.timeout=RandomInt(1 3); m.x=RandomInt(1 1000)
mes f "Convert" m


Macro __SemaphoreReleaser
Code:
Copy      Help
class SemaphoreReleaser -_h

Member function SemaphoreReleaser.
Code:
Copy      Help
ReleaseSemaphore _h 1 0
Note: it is Member function, and its name ends with period.


Messages In This Thread
2 questions... - by ldarrambide - 02-09-2019, 08:58 AM
RE: 2 questions... - by Gintaras - 02-09-2019, 09:47 AM
RE: 2 questions... - by ldarrambide - 02-10-2019, 12:18 PM
RE: 2 questions... - by ldarrambide - 02-10-2019, 06:36 PM
RE: 2 questions... - by Gintaras - 02-10-2019, 07:47 PM
RE: 2 questions... - by ldarrambide - 02-10-2019, 07:58 PM
RE: 2 questions... - by Gintaras - 02-11-2019, 06:45 AM
RE: 2 questions... - by Gintaras - 02-11-2019, 07:07 AM
RE: 2 questions... - by ldarrambide - 02-11-2019, 05:19 PM
RE: 2 questions... - by ldarrambide - 02-12-2019, 05:08 PM
RE: 2 questions... - by Gintaras - 02-12-2019, 05:49 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)