Create {@link EventExecutorGroup} for executing handle methods.

@param size size of threadPool
@return instance of {@link EventExecutorGroup} or {@code null} if {@code size} is {@code <= 0}.
510434
@Nullable
  private EventExecutorGroup createEventExecutorGroup(int size) {
    if (size <= 0) {
      return null;
    }

    ThreadFactory threadFactory = new ThreadFactory() {
      private final ThreadGroup threadGroup = new ThreadGroup(serviceName + "-executor-thread");
      private final AtomicLong count = new AtomicLong(0);

      @Override
      public Thread newThread(Runnable r) {
        Thread t = new Thread(threadGroup, r, String.format("%s-executor-%d", serviceName, count.getAndIncrement()));
        t.setDaemon(true);
        return t;
      }
    };

    UnorderedThreadPoolEventExecutor executor = new UnorderedThreadPoolEventExecutor(size, threadFactory,
                                                                                     rejectedExecutionHandler);
    if (execThreadKeepAliveSecs > 0) {
      executor.setKeepAliveTime(execThreadKeepAliveSecs, TimeUnit.SECONDS);
      executor.allowCoreThreadTimeOut(true);
    }
    return new NonStickyEventExecutorGroup(executor);
  }
921132
public static final ThreadHistoryEvent created(long threadId, String threadName){
		return new ThreadHistoryEvent(threadId, threadName, OPERATION.CREATED);
	}
1024657
public CacheManagerBuilder<T> withDefaultSizeOfMaxObjectGraph(long size) {
    DefaultSizeOfEngineProviderConfiguration configuration = configBuilder.findServiceByClass(DefaultSizeOfEngineProviderConfiguration.class);
    if (configuration == null) {
      return new CacheManagerBuilder<>(this, configBuilder.addService(new DefaultSizeOfEngineProviderConfiguration(DEFAULT_MAX_OBJECT_SIZE, DEFAULT_UNIT, size)));
    } else {
      ConfigurationBuilder builder = configBuilder.removeService(configuration);
      return new CacheManagerBuilder<>(this, builder.addService(new DefaultSizeOfEngineProviderConfiguration(configuration
        .getMaxObjectSize(), configuration.getUnit(), size)));
    }
  }
1207600
public static EventLoopGroup newEventLoopGroup(int numThreads, String threadNamePrefix,
                                                   boolean useDaemonThreads) {

        checkArgument(numThreads > 0, "numThreads: %s (expected: > 0)", numThreads);
        requireNonNull(threadNamePrefix, "threadNamePrefix");

        final TransportType type = TransportType.detectTransportType();
        final String prefix = threadNamePrefix + '-' + type.lowerCasedName();
        return newEventLoopGroup(numThreads, new EventLoopThreadFactory(prefix, useDaemonThreads));
    }
129433
public Memory allocate(long size) {
        if(size == 0L)
            return new OffHeapMemory();

        // Allocate memory of the given size + HEADER space
        long memorySize = size + OffHeapMemory.HEADER_SIZE;
        long address = UnsafeUtil.unsafe.allocateMemory(memorySize);
        Memory m = new OffHeapMemory(address, size);
        register(m);
        return m;
    }
458189
public static StaticMapsRequest newRequest(GeoApiContext context, Size size) {
    return new StaticMapsRequest(context).size(size);
  }
71408
public CollectionAssert hasSizeGreaterThanOrEqualTo(int size) {
		isNotNull();
		int actualSize = size(this.actual);
		if (!(actualSize >= size)) {
			failWithMessage("The size <%s> is not greater or equal to <%s>", actualSize,
					size);
		}
		return this;
	}
103701
@Override
    public EventLoopGroup createEventLoopGroup(int threads, @Nullable Integer ioRatio) {
        return withIoRatio(new EpollEventLoopGroup(threads), ioRatio);
    }
1253452
public static EventLoopGroup createEventLoop(IOMode mode, int numThreads, String threadPrefix) {
    ThreadFactory threadFactory = createThreadFactory(threadPrefix);

    switch (mode) {
      case NIO:
        return new NioEventLoopGroup(numThreads, threadFactory);
      case EPOLL:
        return new EpollEventLoopGroup(numThreads, threadFactory);
      default:
        throw new IllegalArgumentException("Unknown io mode: " + mode);
    }
  }
1254391
public static ThreadPoolExecutor createThreadPoolExecutor(final int queueSize, final String threadName, ThreadFactory threadFactory, final RejectedExecutionHandler policy)
   {
      if (threadFactory == null) {
         threadFactory = new DefaultThreadFactory(threadName, true);
      }

      LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<>(queueSize);
      ThreadPoolExecutor executor = new ThreadPoolExecutor(1 /*core*/, 1 /*max*/, 5 /*keepalive*/, SECONDS, queue, threadFactory, policy);
      executor.allowCoreThreadTimeOut(true);
      return executor;
   }
445723
static <T extends RadixTable> void radixSort(
		final int size,
		final T table,
		final Source<? super T> source,
		final ExecutorService executor
	) {
		try {
			final int numTasks = table.numTasks;

			// Dynamically choose pass size
			/*
			// Must be power of two and less than or equal to 32
			final int BITS_PER_PASS;
			if(size < 0x80000) {
				BITS_PER_PASS = 8;
			} else {
				BITS_PER_PASS = 16;
			}
			final int PASS_SIZE = 1 << BITS_PER_PASS;
			final int PASS_MASK = PASS_SIZE - 1;
			 */

			// The same futures list is used by multiple stages below
			final List<Future<?>> runnableFutures;

			// The size of division of work (number of elements per task).
			final int sizePerTask;

			if(executor==null) {
				assert numTasks==1 : "Must have an executor when numTasks != 1";
				runnableFutures = null;
				sizePerTask = size;
			} else {
				assert numTasks>=2 : "Must not have an executor when numTasks < 2";
				runnableFutures = new ArrayList<>(numTasks);
				int spt = size / numTasks;
				if((spt*numTasks)<size) spt++; // Round-up instead of down
				sizePerTask = spt;
			}

			// Set of all bits seen to skip bit ranges that won't sort.
			int bitsSeen = 0;

			// Set of all bits not seen to skip bit ranges that won't sort.
			int bitsNotSeen = 0;

			// May only use concurrent import for random access sources
			if(executor!=null && source.useRandomAccess()) {
				// Perform concurrent import
				final List<Future<Source.ImportDataResult>> importStepFutures = new ArrayList<>(numTasks);
				for(
					int taskStart=0, toTaskNum=0;
					taskStart<size;
					taskStart+=sizePerTask, toTaskNum++
				) {
					int taskEnd = taskStart + sizePerTask;
					if(taskEnd > size) taskEnd = size;

					final int finalTaskStart = taskStart;
					final int finalTaskEnd   = taskEnd;
					final int finalToTaskNum = toTaskNum;
					importStepFutures.add(
						executor.submit(
							new Callable<Source.ImportDataResult>() {
								@Override
								public Source.ImportDataResult call() {
									return source.importData(table, finalTaskStart, finalTaskEnd, finalToTaskNum);
								}
							}
						)
					);
				}

				// Combine results
				for(Future<Source.ImportDataResult> importStepFuture : importStepFutures) {
					Source.ImportDataResult result = importStepFuture.get();
					bitsSeen |= result.bitsSeen;
					bitsNotSeen |= result.bitsNotSeen;
				}
			} else {
				// Single-threaded import
				Source.ImportDataResult result = source.importData(table, 0, size, 0);
				bitsSeen |= result.bitsSeen;
				bitsNotSeen |= result.bitsNotSeen;
			}
			bitsNotSeen ^= 0xffffffff;

			// Swap toQueues and fromQueues
			table.swapQueues();

			// Perform gather/scatter iterations
			int lastShiftUsed = 0;
			for(int shift=BITS_PER_PASS; shift<32; shift += BITS_PER_PASS) {
				// Skip this bit range when all values have equal bits.  For example
				// when going through the upper bits of lists of all smaller positive
				// or negative numbers.
				if(((bitsSeen>>>shift)&PASS_MASK) != ((bitsNotSeen>>>shift)&PASS_MASK) ) {
					lastShiftUsed = shift;
					if(executor!=null) {
						// Get some final values for anonymous inner class
						final int finalShift = shift;
						// Perform each concurrently with balanced concurrency
						int toTaskNum = 0;
						int taskFromQueueStart = 0;
						int taskTotalLength = 0;
						for(int fromQueueNum=0; fromQueueNum<PASS_SIZE; fromQueueNum++) {
							for(int fromTaskNum=0; fromTaskNum<numTasks; fromTaskNum++) {
								taskTotalLength += table.getFromQueueLength(fromTaskNum, fromQueueNum);
							}
							if(
								taskTotalLength>0 // Skip no output, such as all handle in previous tasks
								&& (
									taskTotalLength >= sizePerTask // Found fair share (or more)
									|| fromQueueNum==PASS_MASK // or is last task
								)
							) {
								final int finalToTaskNum = toTaskNum;
								final int finalTaskFromQueueStart = taskFromQueueStart;
								final int taskFromQueueEnd = fromQueueNum + 1;
								// Gather/scatter concurrent
								assert runnableFutures != null;
								runnableFutures.add(
									executor.submit(
										new Runnable() {
											@Override
											public void run() {
												for(int fromQueueNum=finalTaskFromQueueStart; fromQueueNum<taskFromQueueEnd; fromQueueNum++) {
													table.gatherScatter(
														finalShift,
														fromQueueNum,
														finalToTaskNum
													);
												}
											}
										}
									)
								);

								// Reset to next task
								toTaskNum++;
								taskFromQueueStart = taskFromQueueEnd;
								taskTotalLength = 0;
							}
						}
						// Wait for each gather/scatter task to complete
						assert runnableFutures != null;
						waitForAll(runnableFutures);
						runnableFutures.clear();
					} else {
						for(int fromQueueNum=0; fromQueueNum<PASS_SIZE; fromQueueNum++) {
							table.gatherScatter(shift, fromQueueNum, 0);
						}
					}

					// Swap from and to
					table.swapQueues();
				}
			}

			// Negative before positive to perform as signed integers
			int fromQueueStart = (lastShiftUsed+BITS_PER_PASS)==32 ? (PASS_SIZE>>>1) : 0;

			// May only use concurrent export for random access sources
			if(executor!=null && source.useRandomAccess()) {
				// Use indexed strategy with balanced concurrency
				final int fromQueueLast = (fromQueueStart-1) & PASS_MASK;
				int taskFromQueueStart = fromQueueStart;
				int taskOutIndex = 0;
				int taskTotalLength = 0;
				int fromQueueNum = fromQueueStart;
				do {
					for(int fromTaskNum=0; fromTaskNum<numTasks; fromTaskNum++) {
						taskTotalLength += table.getFromQueueLength(fromTaskNum, fromQueueNum);
					}
					if(
						taskTotalLength>0 // Skip no output, such as all handle in previous tasks
						&& (
							taskTotalLength >= sizePerTask // Found fair share (or more)
							|| fromQueueNum==fromQueueLast // or is last task
						)
					) {
						final int finalTaskFromQueueStart = taskFromQueueStart;
						final int finalTaskOutIndex = taskOutIndex;
						final int finalTaskFromQueueEnd = (fromQueueNum + 1) & PASS_MASK;
						// Queue concurrent
						assert runnableFutures != null;
						runnableFutures.add(
							executor.submit(
								new Runnable() {
									@Override
									public void run() {
										source.exportData(
											table,
											finalTaskFromQueueStart,
											finalTaskFromQueueEnd,
											finalTaskOutIndex
										);
									}
								}
							)
						);

						// Reset to next task
						taskFromQueueStart = finalTaskFromQueueEnd;
						taskOutIndex      += taskTotalLength;
						taskTotalLength    = 0;
					}
				} while(
					(fromQueueNum = (fromQueueNum + 1) & PASS_MASK)
					!= fromQueueStart
				);
				// Wait for each export task to complete
				waitForAll(runnableFutures);
				// This is the last stage, not needed: runnableFutures.clear()
			} else {
				// Use indexed strategy, single-threaded
				source.exportData(
					table,
					fromQueueStart,
					fromQueueStart,
					0
				);
			}
		} catch(InterruptedException | ExecutionException e) {
			throw new WrappedException(e);
		}
	}
1117699
public static ScheduledExecutorService newScheduledThreadPool(int size, String poolName) {
        // Caller runs only occurs after shutdown, as queue size is unbounded.
        ScheduledThreadPoolExecutor result = new ScheduledThreadPoolExecutor(size, getThreadFactory(poolName), new CallerRuns());

        // Do not execute any periodic tasks after shutdown.
        result.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);

        // Do not execute any delayed tasks after shutdown.
        result.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);

        // Remove tasks from the executor once they are done executing. By default, even when canceled, these tasks are
        // not removed; if this setting is not enabled we could end up with leaked (and obsolete) tasks.
        result.setRemoveOnCancelPolicy(true);
        return result;
    }
327027
public static AreaI area(final AreaSizeI size)
  {
    Objects.requireNonNull(size, "Size");
    return AreaI.of(0, size.sizeX(), 0, size.sizeY());
  }
111380
protected <K, V> Map<K, V> allocMap(int size) {
      return size == 0 ? Collections.emptyMap() : new HashMap<>(size * 4/3, 0.75f);
   }
889351
public int[] get(int size) {
        if (array == null || size > array.length)
            return array = new int[size];

        return array;
    }
1141873
public AllWindowedStream<T, GlobalWindow> countWindowAll(long size) {
		return windowAll(GlobalWindows.create()).trigger(PurgingTrigger.of(CountTrigger.of(size)));
	}
1259732
public WindowedStream<T, KEY, GlobalWindow> countWindow(long size) {
		return window(GlobalWindows.create()).trigger(PurgingTrigger.of(CountTrigger.of(size)));
	}