Hello all...
-- A while back, I saw a post from Bob which mentioned AbtTimedWait, and how it offered a reliable delay, without pinning the CPU. There are a few instances in my software, where I need to use a delay of some kind, and I have been using Delay. One example, is to start a repeating procedure on a specified interval. For this, I would fork a Process, then use a delay, followed by the appropriate code. Yes, there are also checks to ensure the procedure is still enabled, and such...but at its base level, it is mainly wait for x seconds, do the thing, and repeat. I have never noticed anything untoward, by using (Delay forMilliseconds: x) wait, but I like the idea of the AbtTimedWait minimizing CPU cycles. The reason I am asking about this, is that there are no references to AbtTimedWait in the VA base code (at least in what I have loaded), but numerous references to Delay. Is that simply because AbtTimedWait is newer? Or are there downsides to using it? I appreciate any thoughts.... Best Regards, Julian Ford You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/f835ffd8-8eaf-4bad-a683-ae8354ee3231o%40googlegroups.com. |
Hi Julian, I think "Delay >> wait" will block the current Smalltalk process.... So you may want to do that in a separate Smalltalk process...not the UI process. The AbtTimedWait does slightly different. In Windows, for example, this is just calling the Windows API "Sleep" function on a separate thread so it won't block the main vm process (see AbtTimedWait >> #useThreadMethod). Aside from that, AbtTimedWait allows a much higher resolution on the time to wait. The default 'Delay class >> interruptPeriod' is 100 ms. So if you need less than that, then you should use AbtTimedWait or else change Delay's interruptPeriod. Finally, you might want to look at SstCron (Load Sst Base feature) as it can manage long running tasks. For example, to print "Fire!" to the Transcript every 5 seconds, you would do: SstCron default add: ( SstCronEntry new workBlock: [Transcript show: 'Fire!']; seconds: 5). Others may have additional thoughts. Best regards, On Thu, Jul 2, 2020 at 12:36 PM Julian Ford <[hidden email]> wrote:
Mariano Martinez Peck Software Engineer, Instantiations Inc. Email: [hidden email] Twitter: https://twitter.com/MartinezPeck Blog: https://marianopeck.wordpress.com/You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/CAOUkibEDSD00Yxz82SEX7z2eEPFi8FMazmkA4WBHTQ70iOukpA%40mail.gmail.com. |
Hi, Mariano.
-- Thank you for the reply! I should have mentioned that I am using strictly a Windows environment. Yes, I am always using the Delay in a separate Smalltalk Process. The idea is along the lines of.... [ [ self loopIsEnabled ] whileTrue: [ AbtTimedWait forSeconds: 5. self loopIsEnabled ifTrue: [ self doSomethingInteresting ]. ]. ] fork. The resolution is good to know about, but probably not as significant an issue. I use this sort of thing, for example, to have the system check for incoming SMS Text messages every 10 minutes, or to perform a database dump every hour. I will definitely look up SstCron, as you suggested....sounds interesting! I hope you and your family are safe and healthy!!!!!! Regards, Julian On Thursday, July 2, 2020 at 11:55:42 AM UTC-4, Mariano Martinez Peck wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/6b8a7dc6-6b70-48e9-af17-5000812c63deo%40googlegroups.com. |
Julian, Mariano brought up SstCron, which also was my first thought when I read your question. We've been using it in Kontolino! for years now to regularly log the health status of our servers, which can then easily be monitored by external tools. We also do some job scheduling for maintenance of our DB and such. It's rock solid and reliable and doesn't put a load burden onto our server images. Plus: it's just like cron, so if you are familiar with Cron jobs and the crontab file on linux, you know exactly how to use SstCron. There is one caveat, however: What it doesn't do is wait a certain amount of time after a job is done. It just starts off a new copy of it in defined intervals. So if you need to make sure the last run is finished before a new job starts, you have to implement something to keep the new/next job(s) from starting as long a s another one is still active. AFAIK, there is no built-in mechanism for such a thing in VAST (just like in Cron). So if your requirement is that some job may take 5 seconds or maybe sometimes 12 minutes and you want the next one to start exactly 2 minutes aftre the last one finished, SstCron is probably not your best friend. Joachim (still looking for Mirto rosso in my local stores) [hidden email] schrieb am Donnerstag, 2. Juli 2020 um 18:37:29 UTC+2:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/c98523fc-bd93-4f56-a7cf-ebf97aacee01n%40googlegroups.com. |
In reply to this post by rjuli...@gmail.com
I just observed 100% CPU usage with something like '[(Delay forSeconds: 5) wait] repeat' under Linux. Using AbtTimedWait works fine. Cheers, Adriaan. You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/c9f8c97c-7f5b-409f-85f6-3b76d457063do%40googlegroups.com. |
You are waiting in the Main-Execution
(U) thread - this is called busy waiting.
Am 08.07.20 um 21:58 schrieb Adriaan
van Os:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/886b925f-6007-b92b-47c3-e14dcda288a2%40feldtmann.online. |
I forgot to mention, this was with a headless runtime....
-- On Wednesday, July 8, 2020 at 10:19:32 PM UTC+2, Marten Feldtmann wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/0297df8a-a3bb-4d30-a4d5-fff4f8d4a443o%40googlegroups.com. |
It's still the main thread. If you fork it you won't get that.
Esteban A. Maringolo On Wed, Jul 8, 2020 at 5:33 PM Adriaan van Os <[hidden email]> wrote: > > I forgot to mention, this was with a headless runtime.... > > On Wednesday, July 8, 2020 at 10:19:32 PM UTC+2, Marten Feldtmann wrote: >> >> You are waiting in the Main-Execution (U) thread - this is called busy waiting. >> > -- > You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. > To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/0297df8a-a3bb-4d30-a4d5-fff4f8d4a443o%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/CAJMgPCJjHgyGsMwEqs%3DfBuk%3DWS5TsrNWDPqpxnNB4PhVnbiu4A%40mail.gmail.com. |
Ah, forget all I wrote. The actual code was missing the 'wait'.... :-s
-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/003cc7ce-906a-4dc9-961f-7c0dfe2d95dco%40googlegroups.com. |
Administrator
|
On Wednesday, July 8, 2020 at 2:05:40 PM UTC-7, Adriaan van Os wrote:
--
I'm sorry. I laughed at that. (Knowing how many times I have done something similar!) You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/08702fc0-104f-4c14-840f-17de475108a8o%40googlegroups.com. |
Free forum by Nabble | Edit this page |