Skip to content

Instantly share code, notes, and snippets.

View buchgr's full-sized avatar

Jakob Buchgraber buchgr

  • Rust @google
  • Munich, Germany
  • 05:17 (UTC -12:00)
View GitHub Profile
#include <cstdio>
#include <cstdlib>
#include "cycle.h"
const short NFUNCS = 24;
template<int N>
int fN(int x) {
return fN<N-1>(fN<N-1>(x));
}
// gcc callbench.c -o callbench -O1
#include <stdio.h>
#include <stdlib.h>
#include "cycle.h"
int f0( int x )
{
/* The details of this calculation are not important */
return x;
}
@buchgr
buchgr / gist:3501fd3da7d85ad300a0
Created September 6, 2014 20:16
eventloop shutdown
diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterTest.java
index c5a165c..8f7e29c 100644
--- a/codec-http2/src/test/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterTest.java
+++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterTest.java
@@ -54,7 +54,11 @@ import io.netty.util.NetUtil;
import java.net.InetSocketAddress;
import java.util.List;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
+import java.util.concurrent.TimeUnit;
@buchgr
buchgr / EventLoop.java
Created August 4, 2014 20:50
Pooling of ForkJoinTasks.
import java.util.concurrent.Executor;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.RunnableFuture;
public class EventLoop implements Runnable {
final Executor executor;
final AdaptedRunnable pool[] = new AdaptedRunnable[2];
volatile int cnt;
EventLoop(Executor executor) {
/*
* Copyright 2014 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
// The problem of associating tasks to channels could be solved by
// having the developer tell us, which channel a task belongs to
// this would make filtering the tasks on migration very easy.
// The downside is that it is subject to user errors.
//
// null if it doesn't belong to any particular channel
execute(ch, new Runnable() {
@Override
public void run() {
ch.flush();
// Hi there! I just want to let you know that I have neither compiled nor run
// this code.
EventLoopGroup workerGroup = new NioEventLoopGroup(32, new CustomEventExecutorChooser());
public interface EventExecutorChooser {
void addExecutor(EventExecutor executor)
MetricsProvider newMetricsProvider();
EventExecutor next();
}
// Welcome back! I just wrote down this code from the top of my head to express the main ideas.
// I didn't compile or run it. It's mostly pseudocode anyway.
// The problem of associating tasks to channels could be solved by
// having the developer tell us, which channel a task belongs to
// this would make filtering the tasks on migration very easy.
// The downside is that it is subject to user errors.
//
// null if it doesn't belong to any particular channel
package palantir;
import java.util.Comparator;
public class FileNameComparator implements Comparator<String>
{
/*
* DESCRIPTION:
* Numbers in the string are compared by their natural order
* and not their ASCII order. (2 < 10)
import java.util.Arrays;
import java.util.Scanner;
public class Solution {
private static int discoverSink(int[][] farmland, int[][] basins, int nextbasin, int i, int j) {
if (basins[i][j] != 0) {
return basins[i][j];
// perform a dfs starting at i,j searching for a sink
} else {
int minaltitude = farmland[i][j];