public void close() { this.shouldClose = true; } }
/** * The main loop */ @Override public void run(SourceContext<T> sourceContext) throws Exception { int elements = loadPerTimeslice(); while (running) { long emitStartTime = System.currentTimeMillis(); for (int i = 0; i < elements; i++) { sourceContext.collect(generateElement()); } // Sleep for the rest of timeslice if needed long emitTime = System.currentTimeMillis() - emitStartTime; if (emitTime < timeSliceLengthMs) { Thread.sleep(timeSliceLengthMs - emitTime); } } sourceContext.close(); }
public void close() { this.shouldClose = true; } }
ctx.close(); if (latencyEmitter != null) { latencyEmitter.close();
ctx.close(); if (latencyEmitter != null) { latencyEmitter.close();
ctx.close(); if (latencyEmitter != null) { latencyEmitter.close();
public void close() { this.shouldClose = true; } }
public void close() { this.shouldClose = true; } }
public void cancel() { // important: marking the source as stopped has to happen before the function is stopped. // the flag that tracks this status is volatile, so the memory model also guarantees // the happens-before relationship markCanceledOrStopped(); userFunction.cancel(); // the context may not be initialized if the source was never running. if (ctx != null) { ctx.close(); } }
public void cancel() { // important: marking the source as stopped has to happen before the function is stopped. // the flag that tracks this status is volatile, so the memory model also guarantees // the happens-before relationship markCanceledOrStopped(); userFunction.cancel(); // the context may not be initialized if the source was never running. if (ctx != null) { ctx.close(); } }
public void cancel() { // important: marking the source as stopped has to happen before the function is stopped. // the flag that tracks this status is volatile, so the memory model also guarantees // the happens-before relationship markCanceledOrStopped(); userFunction.cancel(); // the context may not be initialized if the source was never running. if (ctx != null) { ctx.close(); } }
ctx.close(); if (latencyEmitter != null) { latencyEmitter.close();
public void cancel() { // important: marking the source as stopped has to happen before the function is stopped. // the flag that tracks this status is volatile, so the memory model also guarantees // the happens-before relationship markCanceledOrStopped(); userFunction.cancel(); // the context may not be initialized if the source was never running. if (ctx != null) { ctx.close(); } }