Home » Community » Newbie corner » TIme and Idle
|
Re: TIme and Idle [message #31407 is a reply to message #31401] |
Tue, 01 March 2011 10:42   |
|
Hi Wlad,
Wlad wrote on Tue, 01 March 2011 10:04 | 1. How can I find the time to within one millisecond precision?
|
If I remember correctly, there is GetTicks() function returning the number of miliseconds, which can be used to do this. Most of the time however, such precision is only useful for measuring purposes. If that is your case, have a look at TimeStop class, which provides easy way to measure time intervals with the precision you requested.
Wlad wrote on Tue, 01 March 2011 10:04 | 2. Is it an "OnIdle" event in U++?
|
AFAIK there is no such thing in U++ (but I might be wrong ). It might be possible to "emulate" it using callbacks... Could you describe a bit what do you need it for? In most cases it can be just done in some other way 
Best regards,
Honza
|
|
|
Re: TIme and Idle [message #31410 is a reply to message #31407] |
Tue, 01 March 2011 11:15   |
Wlad
Messages: 20 Registered: February 2010 Location: Ukraine, KharkOv
|
Promising Member |

|
|
Hi, Honza,
dolik.rce wrote on Tue, 01 March 2011 11:42 |
Wlad wrote on Tue, 01 March 2011 10:04 | 1. How can I find the time to within one millisecond precision?
|
If I remember correctly, there is GetTicks() function returning the number of miliseconds, which can be used to do this. Most of the time however, such precision is only useful for measuring purposes. If that is your case, have a look at TimeStop class, which provides easy way to measure time intervals with the precision you requested.
|
TNX!
dolik.rce wrote on Tue, 01 March 2011 11:42 |
Wlad wrote on Tue, 01 March 2011 10:04 | 2. Is it an "OnIdle" event in U++?
| AFAIK there is no such thing in U++ (but I might be wrong ). It might be possible to "emulate" it using callbacks... Could you describe a bit what do you need it for? In most cases it can be just done in some other way 
|
I'll try to explain the roots of the problem.
They are stemmed from VERY large old application developed by an other guy.
It was developed at early 90s and DID NOT use multithreading.
You know... MANY tasks processed in loop, every new sequence of which was initiated by receiving ON_IDLE mrssage...
Now I transform it into U++ «one-to-one» (using analogies).
While it works as «direct copy», I will try to rewrite it using multithreading approach.
|
|
|
Re: TIme and Idle [message #31419 is a reply to message #31410] |
Tue, 01 March 2011 13:18  |
|
Wlad wrote on Tue, 01 March 2011 11:15 | I'll try to explain the roots of the problem.
They are stemmed from VERY large old application developed by an other guy.
It was developed at early 90s and DID NOT use multithreading.
You know... MANY tasks processed in loop, every new sequence of which was initiated by receiving ON_IDLE mrssage...
Now I transform it into U++ «one-to-one» (using analogies).
While it works as «direct copy», I will try to rewrite it using multithreading approach.
|
OK, I understand Simple solution could probably be to use Cowork. Instead of waiting for "OnIdle", you would just post a callback to Cowork which should take care about the threading and scheduling at the same time. It maintains fixed size thread pool, so if you post more jobs than you have available threads, it will be queued and start when something else finishes, which is essentialy the same as idle state. Note that I never did something like this, so take it just as a guess You'll find out if it works only if you try it 
Honza
[Updated on: Tue, 01 March 2011 13:18] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sun Apr 27 22:11:20 CEST 2025
Total time taken to generate the page: 0.00428 seconds
|