Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 46
[AIT-767] uts: live objects ground work#1209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
d51681da2a18595dc9a2fdfdac0607d9bd6e22d4109e215a11605062a92d5e383a66346a689d49322674File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -13,7 +13,9 @@ | ||
| import io.ably.lib.types.Callback; | ||
| import io.ably.lib.types.ErrorInfo; | ||
| import io.ably.lib.types.Param; | ||
| import io.ably.lib.util.Clock; | ||
| import io.ably.lib.util.Log; | ||
| import io.ably.lib.util.SystemClock; | ||
| /** | ||
| * HttpScheduler schedules HttpCore operations to an Executor, exposing a generic async API. | ||
| @@ -286,12 +288,12 @@ public T get() throws InterruptedException, ExecutionException { | ||
| } | ||
| @Override | ||
| public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { | ||
| long remaining = unit.toMillis(timeout), deadline = System.currentTimeMillis() + remaining; | ||
| long remaining = unit.toMillis(timeout), deadline = clock.currentTimeMillis() + remaining; | ||
| synchronized(this) { | ||
| while(remaining > 0) { | ||
| wait(remaining); | ||
| clock.waitOn(this, remaining); | ||
| if(isDone) { break; } | ||
| remaining = deadline - System.currentTimeMillis(); | ||
| remaining = deadline - clock.currentTimeMillis(); | ||
| } | ||
ttypic marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if(!isDone) { | ||
| throw new TimeoutException(); | ||
| @@ -360,6 +362,7 @@ protected synchronized boolean disposeConnection() { | ||
| protected HttpScheduler(HttpCore httpCore, CloseableExecutor executor) { | ||
| this.httpCore = httpCore; | ||
| this.executor = executor; | ||
| this.clock = SystemClock.clockFrom(httpCore.options); | ||
| } | ||
| @Override | ||
| @@ -446,6 +449,7 @@ public <T> Future<T> ablyHttpExecuteWithRetry( | ||
| protected final CloseableExecutor executor; | ||
| private final HttpCore httpCore; | ||
| private final Clock clock; | ||
| protected static final String TAG = HttpScheduler.class.getName(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -27,8 +27,10 @@ | ||
| import io.ably.lib.types.NonRetriableTokenException; | ||
| import io.ably.lib.types.Param; | ||
| import io.ably.lib.util.Base64Coder; | ||
| import io.ably.lib.util.Clock; | ||
| import io.ably.lib.util.Log; | ||
| import io.ably.lib.util.Serialisation; | ||
| import io.ably.lib.util.SystemClock; | ||
| /** | ||
| * Token-generation and authentication operations for the Ably API. | ||
| @@ -921,7 +923,7 @@ else if(!request.keyName.equals(keyName)) | ||
| if(request.timestamp == 0) { | ||
| if(options.queryTime) { | ||
| long oldNanoTimeDelta = nanoTimeDelta; | ||
| long currentNanoTimeDelta = System.currentTimeMillis() - System.nanoTime()/(1000*1000); | ||
| long currentNanoTimeDelta = clock.currentTimeMillis() - clock.nanoTime()/(1000*1000); | ||
| if (timeDelta != Long.MAX_VALUE) { | ||
| /* system time changed by more than 500ms since last time? */ | ||
| @@ -1036,7 +1038,7 @@ public void onAuthError(ErrorInfo err) { | ||
| clearTokenDetails(); | ||
| } | ||
| public static long timestamp() { return System.currentTimeMillis(); } | ||
| public long timestamp() { return clock.currentTimeMillis(); } | ||
ttypic marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
ttypic marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| /******************** | ||
| * internal | ||
| @@ -1050,6 +1052,8 @@ public void onAuthError(ErrorInfo err) { | ||
| */ | ||
| Auth(AblyBase ably, ClientOptions options) throws AblyException { | ||
| this.ably = ably; | ||
| this.clock = SystemClock.clockFrom(options); | ||
| this.nanoTimeDelta = clock.currentTimeMillis() - clock.nanoTime()/(1000*1000); | ||
| authOptions = options; | ||
| tokenParams = options.defaultTokenParams != null ? | ||
| options.defaultTokenParams : new TokenParams(); | ||
| @@ -1304,6 +1308,7 @@ public long serverTimestamp() { | ||
| private static final String TAG = Auth.class.getName(); | ||
| private final AblyBase ably; | ||
| private final Clock clock; | ||
| private final AuthMethod method; | ||
| private AuthOptions authOptions; | ||
| private TokenParams tokenParams; | ||
| @@ -1320,7 +1325,7 @@ public long serverTimestamp() { | ||
| * Time delta between System.nanoTime() and System.currentTimeMillis. If it changes significantly it | ||
| * suggests device time/date has changed | ||
| */ | ||
| private long nanoTimeDelta = System.currentTimeMillis() - System.nanoTime()/(1000*1000); | ||
| private long nanoTimeDelta; | ||
| public static final String WILDCARD_CLIENTID = "*"; | ||
| /** | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.