Skip to content

Commit cb7f27a

Browse files
committed
chore: add @Blocking and @NonBlocking annotations for better documentation
1 parent 3298bcc commit cb7f27a

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

lib/src/main/java/io/ably/lib/realtime/ChannelBase.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ private void setState(ChannelState newState, ErrorInfo reason, boolean resumed,
211211
* Spec: RTL4d
212212
* @throws AblyException
213213
*/
214+
@NonBlocking
214215
public void attach() throws AblyException {
215216
attach(null);
216217
}
@@ -229,6 +230,7 @@ public void attach() throws AblyException {
229230
* This listener is invoked on a background thread.
230231
* @throws AblyException
231232
*/
233+
@NonBlocking
232234
public void attach(CompletionListener listener) throws AblyException {
233235
this.attach(false, listener);
234236
}
@@ -334,6 +336,7 @@ private void attachImpl(final boolean forceReattach, final CompletionListener li
334336
* Spec: RTL5e
335337
* @throws AblyException
336338
*/
339+
@NonBlocking
337340
public void detach() throws AblyException {
338341
detach(null);
339342
}
@@ -357,6 +360,7 @@ public void markAsReleased() {
357360
* This listener is invoked on a background thread.
358361
* @throws AblyException
359362
*/
363+
@NonBlocking
360364
public void detach(CompletionListener listener) throws AblyException {
361365
clearAttachTimers();
362366
detachWithTimeout(listener);
@@ -776,6 +780,7 @@ public interface MessageListener {
776780
* <p>
777781
* Spec: RTL8a, RTE5
778782
*/
783+
@NonBlocking
779784
public synchronized void unsubscribe() {
780785
Log.v(TAG, "unsubscribe(); channel = " + this.name);
781786
listeners.clear();
@@ -804,6 +809,7 @@ protected boolean attachOnSubscribeEnabled() {
804809
* This listener is invoked on a background thread.
805810
* @throws AblyException
806811
*/
812+
@NonBlocking
807813
public synchronized void subscribe(MessageListener listener) throws AblyException {
808814
Log.v(TAG, "subscribe(); channel = " + this.name);
809815
listeners.add(listener);
@@ -821,6 +827,7 @@ public synchronized void subscribe(MessageListener listener) throws AblyExceptio
821827
* <p>
822828
* This listener is invoked on a background thread.
823829
*/
830+
@NonBlocking
824831
public synchronized void unsubscribe(MessageListener listener) {
825832
Log.v(TAG, "unsubscribe(); channel = " + this.name);
826833
listeners.remove(listener);
@@ -841,6 +848,7 @@ public synchronized void unsubscribe(MessageListener listener) {
841848
* This listener is invoked on a background thread.
842849
* @throws AblyException
843850
*/
851+
@NonBlocking
844852
public synchronized void subscribe(String name, MessageListener listener) throws AblyException {
845853
Log.v(TAG, "subscribe(); channel = " + this.name + "; event = " + name);
846854
subscribeImpl(name, listener);
@@ -859,6 +867,7 @@ public synchronized void subscribe(String name, MessageListener listener) throws
859867
* <p>
860868
* This listener is invoked on a background thread.
861869
*/
870+
@NonBlocking
862871
public synchronized void unsubscribe(String name, MessageListener listener) {
863872
Log.v(TAG, "unsubscribe(); channel = " + this.name + "; event = " + name);
864873
unsubscribeImpl(name, listener);
@@ -876,6 +885,7 @@ public synchronized void unsubscribe(String name, MessageListener listener) {
876885
* This listener is invoked on a background thread.
877886
* @throws AblyException
878887
*/
888+
@NonBlocking
879889
public synchronized void subscribe(String[] names, MessageListener listener) throws AblyException {
880890
Log.v(TAG, "subscribe(); channel = " + this.name + "; (multiple events)");
881891
for(String name : names)
@@ -894,6 +904,7 @@ public synchronized void subscribe(String[] names, MessageListener listener) thr
894904
* <p>
895905
* This listener is invoked on a background thread.
896906
*/
907+
@NonBlocking
897908
public synchronized void unsubscribe(String[] names, MessageListener listener) {
898909
Log.v(TAG, "unsubscribe(); channel = " + this.name + "; (multiple events)");
899910
for(String name : names)
@@ -1546,6 +1557,7 @@ public void getMessageVersionsAsync(String serial, Param[] params, Callback<Asyn
15461557
* @return A {@link PaginatedResult} object containing an array of {@link Message} objects.
15471558
* @throws AblyException
15481559
*/
1560+
@Blocking
15491561
public PaginatedResult<Message> history(Param[] params) throws AblyException {
15501562
return historyImpl(ably.http, params).sync();
15511563
}
@@ -1579,6 +1591,7 @@ PaginatedResult<Message> history(Http http, Param[] params) throws AblyException
15791591
* @param callback Callback with {@link AsyncPaginatedResult} object containing an array of {@link Message} objects.
15801592
* @throws AblyException
15811593
*/
1594+
@NonBlocking
15821595
public void historyAsync(Param[] params, Callback<AsyncPaginatedResult<Message>> callback) {
15831596
historyAsync(ably.http, params, callback);
15841597
}
@@ -1609,6 +1622,7 @@ private BasePaginatedQuery.ResultRequest<Message> historyImpl(Http http, Param[]
16091622
* @param options A {@link ChannelOptions} object.
16101623
* @throws AblyException
16111624
*/
1625+
@NonBlocking
16121626
public void setOptions(ChannelOptions options) throws AblyException {
16131627
this.setOptions(options, null);
16141628
}
@@ -1621,6 +1635,7 @@ public void setOptions(ChannelOptions options) throws AblyException {
16211635
* @param listener An optional listener may be provided to notify of the success or failure of the operation.
16221636
* @throws AblyException
16231637
*/
1638+
@NonBlocking
16241639
public void setOptions(ChannelOptions options, CompletionListener listener) throws AblyException {
16251640
this.options = options;
16261641
this.messageEditsMixin = new MessageEditsMixin(basePath, ably.options, options, ably.auth);

lib/src/main/java/io/ably/lib/rest/Auth.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import io.ably.lib.util.Base64Coder;
3030
import io.ably.lib.util.Log;
3131
import io.ably.lib.util.Serialisation;
32+
import org.jetbrains.annotations.Blocking;
33+
import org.jetbrains.annotations.NonBlocking;
3234

3335
/**
3436
* Token-generation and authentication operations for the Ably API.
@@ -663,6 +665,7 @@ public interface TokenCallback {
663665
* @return A {@link TokenDetails} object.
664666
* @throws AblyException
665667
*/
668+
@Blocking
666669
public TokenDetails authorize(TokenParams params, AuthOptions options) throws AblyException {
667670
/* Spec: RSA10g */
668671
if (options != null)
@@ -700,6 +703,7 @@ public TokenDetails authorize(TokenParams params, AuthOptions options) throws Ab
700703
* Alias of authorize() (0.9 RSA10l)
701704
*/
702705
@Deprecated
706+
@Blocking
703707
public TokenDetails authorise(TokenParams params, AuthOptions options) throws AblyException {
704708
Log.w(TAG, "authorise() is deprecated and will be removed in 1.0. Please use authorize() instead");
705709
return authorize(params, options);
@@ -722,6 +726,7 @@ public TokenDetails authorise(TokenParams params, AuthOptions options) throws Ab
722726
* @return A {@link TokenDetails} object.
723727
* @throws AblyException
724728
*/
729+
@Blocking
725730
public TokenDetails requestToken(TokenParams params, AuthOptions tokenOptions) throws AblyException {
726731
/* Spec: RSA8e */
727732
tokenOptions = (tokenOptions == null) ? this.authOptions : tokenOptions.copy();
@@ -885,6 +890,7 @@ public TokenDetails handleResponse(HttpCore.Response response, ErrorInfo error)
885890
* @return A {@link TokenRequest} object.
886891
* @throws AblyException
887892
*/
893+
@Blocking
888894
public TokenRequest createTokenRequest(TokenParams params, AuthOptions options) throws AblyException {
889895
/* Spec: RSA9h */
890896
options = (options == null) ? this.authOptions : options.copy();
@@ -1010,6 +1016,7 @@ public AuthOptions getAuthOptions() {
10101016
* Please use {@link Auth#renewAuth} instead
10111017
*/
10121018
@Deprecated
1019+
@NonBlocking
10131020
public TokenDetails renew() throws AblyException {
10141021
TokenDetails tokenDetails = assertValidToken(this.tokenParams, this.authOptions, true);
10151022
ably.onAuthUpdated(tokenDetails.token, false);
@@ -1024,6 +1031,7 @@ public TokenDetails renew() throws AblyException {
10241031
* Please note that completion callback {@link RenewAuthResult#onCompletion(boolean, TokenDetails, ErrorInfo)}
10251032
* is called on a background thread.
10261033
*/
1034+
@NonBlocking
10271035
public void renewAuth(RenewAuthResult result) throws AblyException {
10281036
final TokenDetails tokenDetails = assertValidToken(this.tokenParams, this.authOptions, true);
10291037

lib/src/main/java/io/ably/lib/rest/ChannelBase.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ PublishResult publishWithResult(Http http, String name, Object data) throws Ably
103103
* @deprecated Use {@link #publishAsync(String, Object, Callback)} instead.
104104
*/
105105
@Deprecated
106+
@NonBlocking
106107
public void publishAsync(String name, Object data, CompletionListener listener) {
107108
publishAsync(ably.http, name, data, listener);
108109
}
@@ -247,6 +248,7 @@ public void execute(HttpScheduler http, final Callback<PublishResult> callback)
247248
* @return an array of Messages for this Channel.
248249
* @throws AblyException
249250
*/
251+
@Blocking
250252
public PaginatedResult<Message> history(Param[] params) throws AblyException {
251253
return history(ably.http, params);
252254
}
@@ -261,6 +263,7 @@ PaginatedResult<Message> history(Http http, Param[] params) throws AblyException
261263
* @param callback
262264
* @return
263265
*/
266+
@NonBlocking
264267
public void historyAsync(Param[] params, Callback<AsyncPaginatedResult<Message>> callback) {
265268
historyAsync(ably.http, params, callback);
266269
}
@@ -296,6 +299,7 @@ public class Presence {
296299
* @return A {@link PaginatedResult} object containing an array of {@link PresenceMessage} objects.
297300
* @throws AblyException
298301
*/
302+
@Blocking
299303
public PaginatedResult<PresenceMessage> get(Param[] params) throws AblyException {
300304
return get(ably.http, params);
301305
}
@@ -321,10 +325,12 @@ PaginatedResult<PresenceMessage> get(Http http, Param[] params) throws AblyExcep
321325
* <p>
322326
* This callback is invoked on a background thread.
323327
*/
328+
@NonBlocking
324329
public void getAsync(Param[] params, Callback<AsyncPaginatedResult<PresenceMessage>> callback) {
325330
getAsync(ably.http, params, callback);
326331
}
327332

333+
@NonBlocking
328334
void getAsync(Http http, Param[] params, Callback<AsyncPaginatedResult<PresenceMessage>> callback) {
329335
getImpl(http, params).async(callback);
330336
}
@@ -356,6 +362,7 @@ private BasePaginatedQuery.ResultRequest<PresenceMessage> getImpl(Http http, Par
356362
* @return A {@link PaginatedResult} object containing an array of {@link PresenceMessage} objects.
357363
* @throws AblyException
358364
*/
365+
@Blocking
359366
public PaginatedResult<PresenceMessage> history(Param[] params) throws AblyException {
360367
return history(ably.http, params);
361368
}
@@ -387,6 +394,7 @@ PaginatedResult<PresenceMessage> history(Http http, Param[] params) throws AblyE
387394
* This callback is invoked on a background thread.
388395
* @throws AblyException
389396
*/
397+
@NonBlocking
390398
public void historyAsync(Param[] params, Callback<AsyncPaginatedResult<PresenceMessage>> callback) {
391399
historyAsync(ably.http, params, callback);
392400
}

0 commit comments

Comments
 (0)