[Ndn-lib] is jNDN thread-safe

Teng Liang philoliang at email.arizona.edu
Thu Jun 8 15:35:31 PDT 2017

Hi Jeff,

The current implementation is not on Android, but we do plan to deploy 
it on Android later.

In my scenario, each node is running an NFD with an NDN consumer and 
producer. Can they use the same face to communicate with the local NFD? 
If they are using two different faces, the local producer can answer the 
Interest from the local consumer, which affects the design. For the 
implementation, I try to run the consumer and producer on different 
threads in the same class.


On 6/7/17 11:31 PM, Thompson, Jeff wrote:
> .. I should ask? Are you using jNDN on Android or not?
> From: Jeff Thompson <jefft0 at remap.ucla.edu <mailto:jefft0 at remap.ucla.edu>>
> Date: Wednesday, June 7, 2017 at 23:30:00
> To: Teng Liang <philoliang at email.arizona.edu 
> <mailto:philoliang at email.arizona.edu>>, NDN Lib 
> <ndn-lib at lists.cs.ucla.edu <mailto:ndn-lib at lists.cs.ucla.edu>>
> Subject: Re: [Ndn-lib] is jNDN thread-safe
> Hi Teng,
> There are two ways to handle thread safety:
> If you are using the Face class, then your application must call 
> processEvents in the same thread as it calls expressInterest. Some 
> more details are here:
> https://github.com/named-data/jndn/blob/master/src/net/named_data/jndn/Face.java#L1349 
> Or you can use ThreadPoolFace 
> <https://github.com/named-data/jndn/blob/master/src/net/named_data/jndn/ThreadPoolFace.java> 
> which automatically submits calls to expressInterest to the thread 
> pool, and wraps callbacks (like onData) so that they are thread safe. 
> Also, ThreadPoolFace can use AsyncTcpTransport 
> <https://github.com/named-data/jndn/blob/master/src/net/named_data/jndn/transport/AsyncTcpTransport.java> 
> with the same thread pool so that your application doesn’t need to 
> call processEvents at all. See the example application 
> TestGetAsyncThreadPool:
> https://github.com/named-data/jndn/blob/master/examples/src/net/named_data/jndn/tests/TestGetAsyncThreadPool.java 
> Thanks,
> - Jeff T
> On 2017/6/7, 17:46:14, "Ndn-lib on behalf of Teng Liang" 
> <ndn-lib-bounces at lists.cs.ucla.edu 
> <mailto:ndn-lib-bounces at lists.cs.ucla.edu> on behalf of 
> philoliang at email.arizona.edu <mailto:philoliang at email.arizona.edu>> wrote:
>     Hello all,
>     Is jNDN thread-safe? Specifically, can one thread express
>     Interests to
>     one face, while another thread uses the same face to process events?
>     Thanks,
>     Teng
>     _______________________________________________
>     Ndn-lib mailing list
>     Ndn-lib at lists.cs.ucla.edu <mailto:Ndn-lib at lists.cs.ucla.edu>
>     http://www.lists.cs.ucla.edu/mailman/listinfo/ndn-lib

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndn-lib/attachments/20170608/9b4fd167/attachment.html>

More information about the Ndn-lib mailing list