All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.nadron.concurrent.Lanes Maven / Gradle / Ivy

Go to download

Nadron is a high speed socket based java game server written using Netty and Mike Rettig's Jetlang. It is specifically tuned for network based multiplayer games and supports TCP and UDP network protocols.

There is a newer version: 0.7
Show newest version
package io.nadron.concurrent;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadFactory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public enum Lanes
{
	LANES;
	final String serverCores = System.getProperty("jet.lanes");
	final int numOfCores;
	final Lane[] jetLanes;

	@SuppressWarnings("unchecked")
	Lanes()
	{
		final Logger LOG = LoggerFactory.getLogger(Lanes.class);
		
		int cores = 1;
		if (null != serverCores)
		{
			try
			{
				cores = Integer.parseInt(serverCores);
			}
			catch (NumberFormatException e)
			{
				LOG.warn("Invalid server cores {} passed in, going to ignore",serverCores);
				// ignore;
			}
		}
		numOfCores = cores;
		jetLanes = new Lane[cores];
		ThreadFactory threadFactory = new NamedThreadFactory("Lane",true);
		for (int i = 1; i <= cores; i++)
		{
			DefaultLane defaultLane = new DefaultLane("Lane[" + i + "]",
					ManagedExecutor.newSingleThreadExecutor(threadFactory));
			jetLanes[i - 1] = defaultLane;
		}
	}

	public Lane[] getJetLanes()
	{
		return jetLanes;
	}

	public int getNumOfCores()
	{
		return numOfCores;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy