Best way to "do this after another class compiles"?
I have a class with a projection that creates some persistent classes (chunks) and a non-persistent "Daemon" class that I want to have running in the background, doing some processing. The daemon needs to look at the "chunk" classes, and I want it to be simple to start the daemon -- I am currently calling the daemon's start method at the end of the CreateProjection method. When I do this, I get a <CLASS DOES NOT EXIST> error from the daemon when it tries to query against one of the chunk tables. But, if I add a "HANG 5" at the beginning of the daemon start method, this runs fine. I am assuming this is because the chunk class compilations are being jobbed away, so we fire the daemon start method before the compilations finish.
"HANG 5" or similar feels like a bandage solution, and with larger projections that need to compile more chunk classes, 5 seconds might not be enough. Is there a way to programmatically "wait for this compilation to be finished and then do a thing?"
I am also not sure if compilation gets jobbed away, if anyone has any insight into that, that would be wonderful as well.
Please let me know if there is other useful information I can provide. Thank you!
Comments
Would /multicompile=0 force the behavior you want?
Tried /multicompile=0 and did not see a change.
My other thought would be to (carefully!) take out and release the oddDEF lock for the class
//adjust timeout lock +^oddDEF(class):5 //check $test and handle timeouts appropriately write $test 1//make sure this happens lock -^oddDEF(class)#"I"
@Mark Hanson - any thoughts on this one?
I would safegueard the code execution in the daemon by checking %Dictionary.CompiledClass to see if the chunk classes are compiled yet.
This is what I landed on. Since the "setup" part of the daemon only needs to run once at daemon startup, this solution doesn't pose any timing problems/long waits. Thanks!
I would like to see a small code example to understand how to help you.
According to the documentation%Projection.AbstractProjection, there is a parameter DisableMulticompile and methods EndCompile, QueueClass. Do you somehow use them in your code?EndCompile looks like it would be super helpful! I landed on a different solution, but EndCompile looks like it would do exactly what I want.
Also, thanks for noting QueueClass -- I was directly calling $SYSTEM.OBJ.Compile() which is not ideal :)