Re: How to use IO Completion Port to exchange data between two thr
- From: "Anthony Wieser" <newsgroups-sansspam@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Oct 2008 14:33:44 +0100
"Electronic75" <Electronic75@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:E4C55577-967B-4AD1-A690-7A3912891136@xxxxxxxxxxxxxxxx
Thanks a lot Anthony and Joseph your discussion was very interesting for me.
Anthony I thought about your post and the alternative scheme that I could
imagine was like this
Thread1 writes to a queue1 whose flagQueue1Filled is zero and when writing
of a package completed it sets flagQueue1Filled to one and then it writes
incoming packages to queue2 whose flagQueue2Filled is zero it continues to
write in this queue until reader thread reads queue1 and sets
flagQueue1Filled to zero then again after write of current package completed
it sets flagQueue2Filled to one and switches the queue and writes in the
queue1 whose flagQueue1Filled is zero and so on...
Is this scheme what you meant as an alternative to joe's idea.
Not really. I would have a single queue protected by a critical section.
When the producer thread wants to notify the consumer thread, it acquires the critical section,
notes if the queue is empty, and then adds the object to the queue, and posts a message to the
consumer thread if it was empty, and then releases the critical section.
The consumer, on receipt of a message acquires the critical section, and removes one object from the queue, and then releases the critical section. It then processess the object from the queue. These queue related steps can be repeated N times, at which time, you decide you've taken enough time. If the queue is still not empty, you can post a your notification message back to yourself, which will end up at the end of the queue of messages, and as a result schedule you to process the remaining data later.
Anthony Wieser
Wieser Software Ltd
.
- Follow-Ups:
- Re: How to use IO Completion Port to exchange data between two thr
- From: Joseph M . Newcomer
- Re: How to use IO Completion Port to exchange data between two thr
- From: Electronic75
- Re: How to use IO Completion Port to exchange data between two thr
- References:
- How to use IO Completion Port to exchange data between two threads
- From: Electronic75
- Re: How to use IO Completion Port to exchange data between two threads
- From: Joseph M . Newcomer
- Re: How to use IO Completion Port to exchange data between two threads
- From: Anthony Wieser
- Re: How to use IO Completion Port to exchange data between two threads
- From: Joseph M . Newcomer
- Re: How to use IO Completion Port to exchange data between two threads
- From: Anthony Wieser
- Re: How to use IO Completion Port to exchange data between two threads
- From: Joseph M . Newcomer
- Re: How to use IO Completion Port to exchange data between two threads
- From: Anthony Wieser
- Re: How to use IO Completion Port to exchange data between two thr
- From: Electronic75
- How to use IO Completion Port to exchange data between two threads
- Prev by Date: Re: Adding Automation methods to a class without class-wizard?
- Next by Date: Re: Add member variable wizard
- Previous by thread: Re: How to use IO Completion Port to exchange data between two thr
- Next by thread: Re: How to use IO Completion Port to exchange data between two thr
- Index(es):
Relevant Pages
|