Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Callbacks and Timers » PostCallback executes 2 at once?
PostCallback executes 2 at once? [message #25515] Fri, 26 February 2010 17:47 Go to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
Hi Mirek,

i got to kind of a misbehaviour in my software, where i think that PostCallback is not executing in FIFO order..or at least it executes 2 in parallell. is this true?

in a 2 year old post from you
http://www.ultimatepp.org/forum/index.php?t=msg&goto=105 45&
i found

Quote:


Async / Non-blocking. It gets performed when GUI thread goes idle after processing messages (if any).

Callback queue itself is MT protected.

Also, callback gets invoked by GUI thread - it is in fact the best way how worker thread is supposed to communicate with it, means you do not need to worry too much about protecting data, there can only be a single GUI thread, means now two Callbacks from Callback (timer) queue can be processed at the same time.



is this true? could you clarify this? can it happen that a second Callback (which was also posted by PostCallback) gets executed while the first one is still in execution?
Re: PostCallback executes 2 at once? [message #25593 is a reply to message #25515] Tue, 02 March 2010 19:09 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kohait00 wrote on Fri, 26 February 2010 11:47

Hi Mirek,

i got to kind of a misbehaviour in my software, where i think that PostCallback is not executing in FIFO order..or at least it executes 2 in parallell. is this true?

in a 2 year old post from you
http://www.ultimatepp.org/forum/index.php?t=msg&goto=105 45&
i found

Quote:


Async / Non-blocking. It gets performed when GUI thread goes idle after processing messages (if any).

Callback queue itself is MT protected.

Also, callback gets invoked by GUI thread - it is in fact the best way how worker thread is supposed to communicate with it, means you do not need to worry too much about protecting data, there can only be a single GUI thread, means now two Callbacks from Callback (timer) queue can be processed at the same time.



is this true? could you clarify this? can it happen that a second Callback (which was also posted by PostCallback) gets executed while the first one is still in execution?


No, that is impossible.

(I think there is a typo in above text, should be 'no' instead of 'now'...)

Mirek
Re: PostCallback executes 2 at once? [message #25594 is a reply to message #25593] Tue, 02 March 2010 19:11 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
P.S.: I have just checked the queing code:

static void sTimeCallback(dword time, int delay, Callback cb, void *id) {
	TimeEvent *list = tevents();
	TimeEvent *e;
	for(e = list->GetNext(); e != list && time >= e->time; e = e->GetNext());
	TimeEvent *ne = e->InsertPrev();
	ne->time = time;
	ne->cb = cb;
	ne->delay = delay;
	ne->id = id;
}



(in CtrlCore/Timer.cpp)

and it seems ok, two callbacks scheduled for the same time (which is "now" for Posts) are entered into the queue in order...

Mirek
Previous Topic: extracted Timer from Ctrl
Next Topic: Strange crash connected to Timer
Goto Forum:
  


Current Time: Fri Mar 29 15:03:34 CET 2024

Total time taken to generate the page: 0.01459 seconds