|
|
Home » Community » Coffee corner » Thoughts about alternative approach to multithreading
Re: Thoughts about alternative approach to multithreading [message #18682 is a reply to message #18681] |
Thu, 16 October 2008 13:48   |
Mindtraveller
Messages: 917 Registered: August 2007 Location: Russia, Moscow rgn.
|
Experienced Contributor |

|
|
For some time I was thinking about Mirek`s question on CoWork. And couldn`t find how to apply queue approach to Reference/CoWork example natively. The only way I think of is QueueCoWork as pool manager for QueueThread objects which decides which Thread should execute next action depending on their business (i.e. queue lengths). On highest hierarchy level QueueCoWork is received PaintLines message from main thread`s Paint. This event executes main class callback function DoRepaint which manages pooling of low-level callbacks painting the lines. IMO, looks quite ugly:
void QueueCoWork::Manage(Callback1 &cb)
{
int mostFreeThread = -1;
//find most free (unbusy) Thread
queueThreads[mostFreeThread] << cb;
}
void QueueCoWork::ManageTypical(Callback1 &cb)
{
//simply rotate through threads to average tasks count
lastUsedThread = (++lastUsedThread) % queueThreads.GetCount();
queueThreads[lastUsedThread] << cb;
}
//----------------------------------------------------
void MainWindow::OnPaint
{
queueCoWork << THISBACK(PaintLines);
}
void MainWindow::PaintLines()
{
for (int y=0; y<height; ++y)
queueCoWork.ManageTypical(THISBACK1(PaintLine, y));
}
void MainWindow::PaintLine(int y)
{
//paint the y-th line
}
[Updated on: Thu, 16 October 2008 13:50] Report message to a moderator
|
|
|
 |
|
Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: mr_ped on Tue, 14 October 2008 08:27
|
 |
|
Re: Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Wed, 15 October 2008 11:59
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: zsolt on Wed, 15 October 2008 21:49
|
 |
|
Re: Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: zsolt on Thu, 16 October 2008 11:38
|
 |
|
Re: Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Thu, 16 October 2008 15:04
|
 |
|
Re: Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Fri, 14 November 2008 10:15
|
 |
|
Re: Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Tue, 18 November 2008 20:05
|
 |
|
Re: Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Wed, 19 November 2008 10:39
|
 |
|
Re: Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Wed, 19 November 2008 19:38
|
 |
|
Re: Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Thu, 20 November 2008 10:42
|
 |
|
Re: Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Fri, 03 July 2009 18:49
|
 |
|
Re: Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Sun, 05 July 2009 22:08
|
 |
|
Re: Thoughts about alternative approach to multithreading
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Sun, 12 July 2009 08:37
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Sun, 05 July 2009 22:10
|
 |
|
Re: Thoughts about alternative approach to multithreading
By: mr_ped on Tue, 18 November 2008 09:05
|
Goto Forum:
Current Time: Sat Jul 05 18:07:58 CEST 2025
Total time taken to generate the page: 0.03668 seconds
|
|
|