[Ndn-lib] is jNDN thread-safe

Thompson, Jeff jefft0 at remap.ucla.edu
Wed Jun 7 23:31:47 PDT 2017


.. 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/0ac0b684/attachment.html>


More information about the Ndn-lib mailing list