Sort of like:
Code: Select all
Module abc
Procedure init()
EndProcedure
ThreadedCall init()
EndModule
Code: Select all
Module abc
Procedure init()
EndProcedure
ThreadedCall init()
EndModule
Is this close to what you might want?jassing wrote: Sun May 12, 2024 7:54 pm Is there a way to have a procedure called each time a new thread uses the module? (other than having each thread call it)
Sort of like:Code: Select all
Module abc Procedure init() EndProcedure ThreadedCall init() EndModule
Code: Select all
Module abc
Threaded abc_status = 0; 0 = uninitialized, >0 = initialized, 2 = some special status, etc.
Procedure init()
If abc_status = 0
abc_status = 1
Else
ProcedureReturn
EndIf
EndProcedure
EndModule
Code: Select all
module blah
procedure init()
; do some stuff
endprocedure
init()
endmoduleCode: Select all
[module]
global gVar
threaded tVar
procedure init()
gVar =(read some value from database)
endprocedure
procedure initT()
tVar =gVar
endprocedure
init() ; Run on module processed.
threadCall initT(); run on thread usage
endmoduleHere's my last example in a similar vein to demonstrate one way. Final implementation details would be tailored to your use of the module.jassing wrote: Sun May 12, 2024 11:18 pmLike I said long shot, but thought maybe someone saw some way to do it.
thanks for your time.
Code: Select all
Module abc
Global gVar
Threaded tInit = 0; 0 = uninitialized, >0 = initialized
Threaded tVar
Procedure init()
gVar =(read some value from database)
EndProcedure
Procedure initT()
If tInit = 0
tVar = gVar
tInit = 1
Else
ProcedureReturn
EndIf
EndProcedure
;--any other module entry procedures that rely on tVar would include a check at the beginning
Procedure blah()
If not tInit: initT(): Endif ;check if variable values are properly initialized
;remainder of procedure
EndProcedure
init() ; Run on module processed.
EndModuleWell, once I see it seem so the obvious way to go -- I was trying to make this more difficult than neededDemivec wrote: Mon May 13, 2024 12:02 am ;--any other module entry procedures that rely on tVar would include a check at the beginning
Procedure blah()
If not tInit: initT(): Endif ;check if variable values are properly initialized
;remainder of procedure
EndProcedure