ess 'data' .. } } public class MyObjectSizeEstimator extends {@link DefaultObjectSizeEstimator} {{@literal @Override}public int estimateSize(Object o) { if (
o instanceof MyRunnable) {
return ((MyRunnable) o).data.length + 8; } return super.estimateSize(o); } } {@link ThreadPoolExecutor} pool = new {@link MemoryAwareThreadPoolExecutor}( 16, 65536, 1048576, 30, {@link TimeUnit}.SECONDS,
new MyObjectSizeEstimator(), {@link Executors}.defaultThreadFactory());
pool.execute(new MyRunnable(data)); Event execution order
Please note that this executor does not maintain the order of the {@link ChannelEvent}s for the same {@link Channel}. For example, you can even receive a {@code "channelClosed"} event before a{@code "messageReceived"} event, as depicted by the following diagram.For example, the events can be processed as depicted below:
--------------------------------> Timeline --------------------------------> Thread X: --- Channel A (Event 1) --- Channel A (Event 2) ---------------------------> Thread Y: --- Channel A (Event 3) --- Channel B (Event 2) --- Channel B (Event 3) ---> Thread Z: --- Channel B (Event 1) --- Channel B (Event 4) --- Channel A (Event 4) --->
To maintain the event order, you must use {@link OrderedMemoryAwareThreadPoolExecutor}.
@apiviz.has com.facebook.presto.jdbc.internal.netty.util.ObjectSizeEstimator oneway - -
@apiviz.has com.facebook.presto.jdbc.internal.netty.handler.execution.ChannelEventRunnable oneway - - executes