[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Request For Comments: KThread
From:       Waldo Bastian <bastian () suse ! de>
Date:       1999-10-01 8:03:25
[Download RAW message or body]

On Fri, 01 Oct 1999, Don Sanders wrote:
> Would it be a good idea for a threading api to faciliate thread synchronization
> by providing easy to use Critical Sections/Semaphores? I think thread
> synchronization is the trickiest part of multi-threaded programming.
> 
> What would happen if I have some data structure that I want to update without
> blocking the UI? Typically only one thread could update the data structure at a
> time, so I would use a semaphore/critical section to lock the data structure,
> maybe pushing commands to be performed on to a stack (the stack would also
> require a critical section for thread synchronization). In this way I could
> serialize updates to the data structure without blocking the man UI thread for
> any noticeable amount of time.
> 
> This is a pretty common scenario isn't it? Does the proposed API make this easy
> to do? How about other common tasks?

In the proposed API you will have the main thread which should be handling the
Qt event loop and a worker thread. The idea is that a set of datastructures is 
being processed by the worker thread. When the main-thread wants to access 
these datastructures it should suspend the thread (on the first sequence point)
do the access and then resume the thread. Basically this synchronizes both
threads which might not always be what you want.

It would probably be usefull to have a set of "startCritical" / "stopCritical" as well
to allow some form of communication between the two threads without synchronizing
them.

Cheers,
Waldo

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic