473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

threading waiting on message queues

Hello,

Here is my challenge.

I have a thread awaiting events being sent via Queue. Currently I am
checking the count and if there is a count, Dequeue() the next object
and process it. By design, however, this is inefficient usage of CPU
clocks.

A more efficient usage could be to wrap Monitor::Wait() and
Monitor::Pulse() events. If Monitor operations like I think it does, I
should be able to Wait() efficiently forever for the next event to
arrive and before I Dequeue() it. And use Pulse() to signal when a
next event has been Enqueue()d.

Does Wait() wait efficiently for the next pulse to arrive?
Are pulses queued cumulatively?
Or is there only one state (pulsed or not)?
(Not insurmountable if this cannot happen.)

Best regards,
Michael Powell
Nov 17 '05 #1
1 1294
Mike wrote:
Hello,

Here is my challenge.

I have a thread awaiting events being sent via Queue. Currently I am
checking the count and if there is a count, Dequeue() the next object
and process it. By design, however, this is inefficient usage of CPU
clocks.

A more efficient usage could be to wrap Monitor::Wait() and
Monitor::Pulse() events. If Monitor operations like I think it does, I
should be able to Wait() efficiently forever for the next event to
arrive and before I Dequeue() it. And use Pulse() to signal when a
next event has been Enqueue()d.

Does Wait() wait efficiently for the next pulse to arrive?
Yes.
Are pulses queued cumulatively?
No.
Or is there only one state (pulsed or not)?
Yes. The states are more like owned & unowned but the implication is (I
think) what you're looking for: Monitor::Pulse will wake a single waiting
thread a single time.
(Not insurmountable if this cannot happen.)


The docs in MSDN on Montor::Wait, Pulse, PulseAll are pretty thorough - be
sure to start by reading and understanding all of those.

-cd
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lane LiaBraaten | last post by:
I am developing a GUI that uses multiple threading.Threads, and Queue.Queues for communicating between the threads, and threading.Timers for checking the queues. Everything works well (runs to...
4
by: Alban Hertroys | last post by:
Hello all, I need your wisdom again. I'm working on a multi-threaded application that handles multiple data sources in small batches each time. The idea is that there are 3 threads that run...
15
by: chahnaz.ourzikene | last post by:
Hi all, This is the first i post in this newsgroup, i hope my english is not too bad... Let's get straight to the point ! I have a little probleme using threads in my little training example :...
1
by: Ognjen Bezanov | last post by:
Hi, all Thanks all of you who helped me with the threading and queues issue. I am trying to get it working but I am having problems. When I try to run the following: cmddata =...
2
by: Gulshan Oshan | last post by:
I want to implement a simple console that continuously listens for an event from a custom object. I am unable to capture the events from the object. If I subscribe to the events in a windows app...
0
by: Stephen Barrett | last post by:
After reading through the many many many posts on threading, I still don't quite understand how to accomplish a task. Here is an overview of the app I am coding. I am sorry if it is a little...
3
by: Elliot Rodriguez | last post by:
Hi: I am writing a WinForm app that contains a DataGrid control and a StatusBar control. My goal is to update the status bar using events from a separate class, as well as some other simple...
13
by: John | last post by:
I've got some reasonably complex business logic in my C# code, in a class called by a ASP.NET page. This takes around 3-4 seconds to execute. It's not dependent on SQL calls or anything like that....
19
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.