Some help for Daniel from F-Droid project? This is a neat bit of code
that allows apps to directly setup wifi-tether hotspots, which is part
of how we do appswap sharing in F-Droid. 

----- Original message -----
From: Daniel Martí <[email protected]>
Subject: libaccesspoint concurrency help
Date: Tue, 12 May 2015 15:53:52 +0200

Hello guys,

So I've been working on libaccesspoint today, got most features up and
running: https://github.com/mvdan/libaccesspoint

There is only one problem - the list of connected devices is gotten
through ARP, which is cached for up to a few minutes, so you may well be
getting devices that have been disconnected for a bit.

So I'm doing another method for getting clients which are reachable,
which seems like a general case and should be in the library.
"Reachable" is the best way to implement "currently connected" that I
found.

Obviously I cannot do the network I/O of trying to resolve each IP
address on the UI thread. So ideally, for N ip addresses I would fire up
N threads, each would find if the IP address is reachable, and then I
would collect the results and construct another list consisting only of
the IP addresses which were reachable.

Seems easy right? Should be. In Go I could do this with channels and
WaitGroups in 20 lines at most. But I'm not used to concurrency in Java
and so I've been stuck with this for hours.

I'm attaching the diff I currently have. It is very, very wrong. So I'm
asking for pointers because google doesn't seem to be able to answer
"how to write sane concurrency in Java" for me :)

And of course, pull requests welcome if anyone wants to give it a go.

-- 
Daniel Martí - [email protected] - http://mvdan.cc/
PGP: A9DA 13CD F7A1 4ACD D3DE  E530 F4CA FFDB 4348 041C


-- 
  Nathan of Guardian
  [email protected]
_______________________________________________
List info: https://lists.mayfirst.org/mailman/listinfo/guardian-dev
To unsubscribe, email:  [email protected]

Reply via email to