[Ndn-lib] is jNDN thread-safe
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
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:
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:
- 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:
Is jNDN thread-safe? Specifically, can one thread express Interests to
one face, while another thread uses the same face to process events?
Ndn-lib mailing list
Ndn-lib at lists.cs.ucla.edu<mailto:Ndn-lib at lists.cs.ucla.edu>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ndn-lib