View Single Post
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#83
Originally Posted by twoboxen View Post
I would assume leveraging cron would be the most efficient (since I know nothing about alarmd), and I'm really just hoping to avoid a "sleep" based solution. I wouldn't want a bunch of threads spawned each just handling a single purpose event.
Note that threads != processes. Threads are fairly cheap resource-wise (but not free). Of course if your plugin gets a separate process when it executes, but the sleep itself (when necessary) is not a big deal as it's inside the daemon process that is running anyway (also, even in those cases there is one extra thread per event -> we only schedule the next one).

Most of the events I'm thinking about wouldn't need that kind of precision... it could be off by several minutes and it wouldn't matter to me.
Just a caveat, it's not just precision, but speed, too. If it's a sleeper thread, the 'payload' gets executed as quickly as possible (if it's native Qt code -> instantly). If we start from cron it always needs to load libs and startup and whatnot regardless of how complex the plugin is, and would feel a bit like trackerd ('what the hell is he doing with 100% cpu in the background again' syndrome). Don't forget - I'm scheduling, not polling !
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc