I have a function called read() that interacts with some hardware and sometimes it returns the value very quickly and other times it could be very slow. I would like to have a timeout associated with my function read() so that if it takes over maybe a second then the function will timeout. I see people talking about using Boost or multi threading and am not too familiar with either. Can someone help me with this? Thanks.
Niner710 0 Light Poster
Recommended Answers
Jump to Postpost the code how its reading the data.
Jump to PostThat doesn't tell us a thing. Post the read() function that's in the DLL.
Jump to PostIn that case I don't think you would want to cancel the operation without permission of the read() function, especially since you are passing it a pointer to something that could become invalid if the read operating timed out. If read() tried to copy data to that pointer after your …
All 10 Replies
Radical Edward 301 Posting Pro
Niner710 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Niner710 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Niner710 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
nbaztec 45 Posting Pro in Training
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
nbaztec 45 Posting Pro in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.