Boost logo

Boost Users :

Subject: Re: [Boost-users] Looking for a mechanism
From: Keith Bennett (kanezor_at_[hidden])
Date: 2018-09-14 17:54:05


Without more information it'd be hard to say. Are you familiar with Boost
ASIO? It's a common method of handling asynchronous communication, though
how much it can be used in your situation may depend on the particular
hardware interface.

The typical situation for a single-threaded process is to set up an
executor context, maybe set up signal handlers, then make an asynchronous
call using ASIO's objects. When making the asynchronous calls, you provide
a callback function object. Your callback function object may then make
another request during its processing. ASIO handles the under-the-hood
abstraction (and generally simplifies it for most situations). But it's up
to you to ensure that your call sequence is safe: for example ASIO will not
prevent you from making multiple simultaneous writes to the same file
descriptor despite it being unsafe in many situations.

My understanding is that your callback is placed onto a function queue
rather than called directly (contrast to POSIX signals where the OS
interrupts whatever function is running right now). That can hurt your
response performance if you're doing long-running tasks so it's worth
considering.

On Fri, Sep 14, 2018 at 12:03 PM Tim Burgess via Boost-users <
boost-users_at_[hidden]> wrote:

> Hi,
>
>
>
> I’m trying to find a method of solving the problem detailed below using
> Boost (or an alternative:
>
>
>
> 1 – I have to send a series of messages to a hardware device to query its
> internal parameter values at application load-time. This I can do;
>
>
>
> 2 – I have a callback that receives responses from the hardware, though I
> get some replies go missing due to saturation;
>
> 3
>
> - The hardware manufacturer tells me that I should send 1 query then
> wait for the response before sending the next query. I could use Sleep, but
> this depends on a specific wait time and I’m not sure if it suspends all
> processing, including my callback, so this doesn’t look satisfactory.
>
> What I’m looking for is a “wait until response” kind of thing, but I
> haven’t found such a thing so far, though I have found several wait
> routines for handling multiple threads.
>
>
>
> I’d appreciate any guidance as to what to look for, as my searches are
> obviously not asking the right questions.
>
>
>
> Best wishes.
>
>
>
> Tim Burgess
>
> Raised Bar Ltd.
>
> E: tim_at_[hidden]
>
> M: +44 (0)7989 486976
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
Keith Bennett


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net