[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] Minimum working example for libgps
From: |
Gary E. Miller |
Subject: |
Re: [gpsd-dev] Minimum working example for libgps |
Date: |
Tue, 7 Nov 2017 14:39:20 -0800 |
Yo Hal!
On Tue, 07 Nov 2017 13:50:12 -0800
Hal Murray <address@hidden> wrote:
> address@hidden said:
> >> A "main loop" makes sense if you have a typical GUI program.
> > Or any long lasting program. The program has to be looping/sleeping
> > somewhere to be ready for callbacks, user input, or gpsd input.
> Consider a main loop that gets input from X, Y, and Z. What are the
> constraints needed to make a main loop work?
None that I see, from just that requirement.
> If all the APIs have a poll option, you can sleep for a short time
> when all have no input.
Or not sleep.
> If one API has a timeout, you can wait there yet get back often
> enough to poll the others.
Yes, the API timeout is almost equivalent to a main loop sleep.
And all still in one main loop. So I miss the point?
> > I'll bet he does have a loop, he has to be waiting somewhere for
> > the thread to get back to him. Adding another thread is just an
> > overcomplication.
>
> In a thread friendly environment, that code is pretty simple. Yes,
> it's more work if you don't have any threads yet.
And you still need a loop in the gpsd reading thread. So nothing saved.
> > Wherever he is sitting, waaiting for work, that is a loop. Just
> > poll gpsd in there.
>
> If you have a multi-threaded program, none of the read/do loops may
> be the main one. Consider a server with one thread per client.
It happens, but rare and fragile. And you still have loops.
The OP said no loops.
> An alternate way of looking at things is that the OP doesn't like the
> API that gpsd provides.
Hard to say: not like, or not understand?
> The gpsd model is that it gives you all the
> data it gets and you have to pull often enough to keep the buffer
> from clogging. An alternative model is that it digests everything,
> saves the latest values, and you can call in (no blocking) and get
> the latest/current value of X.
Yeah, a request last data mode might be interesting, but then gpsd,
or libgpsd, gets a lot more complicated as it needs to save a lot
of extra state variables.
> Many years ago, I was on the fringe of various API wars. Should the
> API be push, callback, pull, or...? We got pretty good at writing
> tiny adapter modules. They are simple in a thread friendly
> environment. I think the common case was a buffer, a thread, and
> less than a page of code.
If you think you can do it in one page of code, I'd like to see it.
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
address@hidden Tel:+1 541 382 8588
Veritas liberabit vos. -- Quid est veritas?
"If you can’t measure it, you can’t improve it." - Lord Kelvin
pgpq3tKunbO1J.pgp
Description: OpenPGP digital signature
- Re: [gpsd-dev] Minimum working example for libgps, (continued)
- Re: [gpsd-dev] Minimum working example for libgps, Hal Murray, 2017/11/03
- Re: [gpsd-dev] Minimum working example for libgps, David Huichen Dai, 2017/11/04
- Re: [gpsd-dev] Minimum working example for libgps, Eric S. Raymond, 2017/11/04
- Re: [gpsd-dev] Minimum working example for libgps, Gary E. Miller, 2017/11/04
- Re: [gpsd-dev] Minimum working example for libgps, David Huichen Dai, 2017/11/05
- Re: [gpsd-dev] Minimum working example for libgps, Gary E. Miller, 2017/11/06
- Re: [gpsd-dev] Minimum working example for libgps, Hal Murray, 2017/11/07
- Re: [gpsd-dev] Minimum working example for libgps, Gary E. Miller, 2017/11/07
- Re: [gpsd-dev] Minimum working example for libgps, Hal Murray, 2017/11/07
- Re: [gpsd-dev] Minimum working example for libgps,
Gary E. Miller <=
- Re: [gpsd-dev] Minimum working example for libgps, Hal Murray, 2017/11/08
- Re: [gpsd-dev] Minimum working example for libgps, Gary E. Miller, 2017/11/08
Re: [gpsd-dev] Minimum working example for libgps, Gary E. Miller, 2017/11/03
Re: [gpsd-dev] Minimum working example for libgps, Bernd Zeimetz, 2017/11/25