def __init__(self, port, request_handler): """ Initialize and start an HTTP server. Uses a native HTTP server implementation, in this case the com.sun.net.httpserver.HttpServer. @param port: The port on which the server should listen. @type port: int @param request_handler: The request handler class from our generic code. @type request_handler: Any class with a 'handle()' method that can take a RestxHttpRequest. In our case, this is normally the RequestDispatcher class. """ self.request_handler = request_handler self.__native_server = HttpServer.create(InetSocketAddress(port), 5) self.__native_server.createContext(settings.DOCUMENT_ROOT if settings.DOCUMENT_ROOT != "" else "/", __HttpHandler(request_handler)) self.__native_server.setExecutor(Executors.newCachedThreadPool()) self.__native_server.start() log("Listening for HTTP requests on port %d..." % port)
def __init__(self, port, request_handler): """ Initialize and start an HTTP server. Uses a native HTTP server implementation, in this case the com.sun.net.httpserver.HttpServer. @param port: The port on which the server should listen. @type port: int @param request_handler: The request handler class from our generic code. @type request_handler: Any class with a 'handle()' method that can take a RestxHttpRequest. In our case, this is normally the RequestDispatcher class. """ self.request_handler = request_handler self.__native_server = HttpServer.create(InetSocketAddress(port), 5) self.__native_server.createContext( settings.DOCUMENT_ROOT if settings.DOCUMENT_ROOT != "" else "/", __HttpHandler(request_handler)) self.__native_server.setExecutor(Executors.newCachedThreadPool()) self.__native_server.start() log("Listening for HTTP requests on port %d..." % port)
def __init__(self): self.changeUpdate = AsyncEventBus("HighLight", Executors.newCachedThreadPool())
# Sets the maximum number of jobs queued for parallel execution before # starting linear execution of new jobs if System.getProperty("sython.linear_limit") is None: if TRACE: SF_LINEAR_LIMIT = 1024 else: SF_LINEAR_LIMIT = 1024*1024 else: SF_LINEAR_LIMIT = int(System.getProperty("sython.linear_limit")) # Maximum recursion depth of stealing SF_MAX_STEAL = 64 # A thread pool used for the executors SF_POOL = Executors.newCachedThreadPool() # A set of tasks which might be available for stealing. Use a concurrent set so # that it shares information between threads in a stable and relatively # efficient way. Note that a task being in this set does not guarantee it is # not being executed. A locking flag on the 'superFuture' task management # objects disambiguates this to prevent double execution. SF_PENDING = Collections.newSetFromMap(ConcurrentHashMap(SF_MAX_CONCURRENT*128,0.75,SF_MAX_CONCURRENT+1)) # All parallel jobs get a job number which is globally unique # and increasing. This is used for logging and cycle checking # and any other house keeping which requires a unique id across # jobs. SF_JOB_NUMB = AtomicLong() # Tracks how many threads are waiting for other threads