MCPcopy Index your code
hub / github.com/grpc/grpc-java / withDeadline

Method withDeadline

api/src/context/java/io/grpc/Context.java:298–313  ·  view source on GitHub ↗

Create a new context which will cancel itself at the given Deadline. The returned context will cascade cancellation of its parent. Callers may explicitly cancel the returned context prior to the deadline just as for #withCancellation(). If the unit of work completes before the deadli

(Deadline newDeadline, ScheduledExecutorService scheduler)

Source from the content-addressed store, hash-verified

296 * </pre>
297 */
298 public CancellableContext withDeadline(Deadline newDeadline, ScheduledExecutorService scheduler) {
299 checkNotNull(newDeadline, "deadline");
300 checkNotNull(scheduler, "scheduler");
301 Deadline existingDeadline = getDeadline();
302 boolean scheduleDeadlineCancellation = true;
303 if (existingDeadline != null && existingDeadline.compareTo(newDeadline) <= 0) {
304 // The new deadline won't have an effect, so ignore it
305 newDeadline = existingDeadline;
306 scheduleDeadlineCancellation = false;
307 }
308 CancellableContext newCtx = new CancellableContext(this, newDeadline);
309 if (scheduleDeadlineCancellation) {
310 newCtx.setUpDeadlineCancellation(newDeadline, scheduler);
311 }
312 return newCtx;
313 }
314
315 /**
316 * Create a new context with the given key value set. The new context will cascade cancellation

Calls 4

checkNotNullMethod · 0.95
getDeadlineMethod · 0.95
compareToMethod · 0.95