jclouds-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Phillips <andr...@apache.org>
Subject Fw: Is SwiftApi is thread safe?
Date Tue, 22 Dec 2015 09:47:11 GMT
Hi all

Prompted by the question below on user@j.a.o: what is the thread-safety 
status of an API returned via ContextBuilder...buildApi?

Context themselves are supposed to be thread-safe [1], but an API 
context's getApi method is documented as:

"Threadsafe implementations will return a singleton." [2]

This could be taken to imply that *the API itself* might not be 
threadsafe (in which case getApi may end up returning a different 
instance for diffrent calls).

Given that, what can be concluded for the result of buildApi:

1. Thread-safe
2. Not thread-safe: pass the context around and all getApi on that when 
3. Depends on the API implementation
4. Other




[1] https://jclouds.apache.org/start/concepts/#contexts

On 2015-12-22 06:23, Kiran Singh wrote:
> Hi
> My name is Kiran Singh and i am using jCloud openstacks-swift library
> to connect with Swift server. I want to write a multi-threaded
> application.
> For making connection to swift server i am using following code:
> SwiftApi swiftApi = ContextBuilder.newBuilder(provider)
>                 .endpoint(endUrl)
>                 .credentials(identity, credential)
>                 .buildApi(SwiftApi.class);
> My question is SwiftApi is thread safe?
> Can i use Singleton object of swiftApi for each thread or do i need to
> create swiftApi object for each thread?
> Thanks in advance
> Kiran Singh

View raw message