This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/sha256" | |
"fmt" | |
"io" | |
"log" | |
"net" | |
"sync/atomic" | |
"time" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <atomic> | |
#include <chrono> | |
#include <ctime> | |
#include <iomanip> | |
#include <iostream> | |
#include <memory> | |
#include <sstream> | |
#include <string> | |
#include <thread> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <thread> | |
#include <mutex> | |
#include <condition_variable> | |
#include <deque> | |
#include <string> | |
#include <iostream> | |
#include <utility> | |
class semaphore { | |
public: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"sync" | |
"sync/atomic" | |
"time" | |
) | |
var pool *sync.Pool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <thread> | |
#include <deque> | |
#include <mutex> | |
#include <condition_variable> | |
struct queue { | |
void put(int x) { | |
std::unique_lock<std::mutex> guard(lock); | |
q.push_back(x); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <utility> | |
template <typename T> constexpr size_t align_to(size_t n) { | |
return (n + alignof(T) - 1) & -alignof(T); | |
} | |
template <typename T> constexpr size_t skip(size_t n) { | |
return align_to<T>(n) + sizeof(T); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"container/deque" | |
"fmt" | |
gio "graph/io" | |
"io" | |
"math" | |
"os" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <memory> | |
#include <vector> | |
#include <algorithm> | |
#include <array> | |
struct data { | |
data(char c) { std::fill(begin(blk), end(blk), c); } | |
std::array<char, (1 << 20)> blk; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"bytes" | |
"container/stack" | |
"flag" | |
"fmt" | |
gio "graph/io" | |
"io" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// c++/clang++ -pthread --std=c++11 delay-call.cc -o delay-call | |
#include <iostream> | |
#include <functional> | |
#include <thread> | |
#include <mutex> | |
#include <condition_variable> | |
#include <chrono> | |
#include <queue> | |
#include <ctime> |