Skip to content

Instantly share code, notes, and snippets.

Avatar

Alkis Evlogimenos alkis

View GitHub Profile
View sequence-benchmark.cc
template <class Sync>
void Sequence(benchmark::State& state) {
static Sync sync;
static std::atomic<uint64> pseq{0};
static uint64 cseq{0};
std::priority_queue<int, std::vector<int>, std::greater<int>> queue;
typename Sync::Mem mem;
for (auto _ : state) {
uint64 p = pseq.fetch_add(std::memory_order_relaxed);
sync.Run(&mem, [&, p] {
View callback-chain.h
#ifndef XXX_COMMON_THREAD_CALLBACK_CHAIN_H_
#define XXX_COMMON_THREAD_CALLBACK_CHAIN_H_
#include <atomic>
#include <cstring>
#include <utility>
#include "third_party/absl/container/internal/container_memory.h"
#include "third_party/absl/container/internal/layout.h"
@alkis
alkis / the-case-for-deadlines.md
Last active Apr 19, 2018
The case for deadlines
View the-case-for-deadlines.md

The case for deadlines

Rust aims to be the foundation of fast and robust software. A thorn in that side is the choice of timeout-centric APIs for I/O and multithreading. I posit this was a bad choice and it needs to be remedied as soon as possible before more APIs proliferate this (possibly accidental) design decision.

Motivating example: time limited network client request

Task: connect to a remote server, send a request, receive response with an end-to-end timeout of 10 seconds.

Attempt #1

@alkis
alkis / multi-versioning.cc
Last active Oct 20, 2016
c++ library multiversioning
View multi-versioning.cc
// Copyright 2016 Google Inc.
//
// Licensed 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
// distributed under the License is distributed on an "AS IS" BASIS,
View gist:550422
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:ng="http://angularjs.org">
<head>
<script type="text/javascript"
src="http://angularjs.org/ng/js/angular-debug.js" ng:autobind></script>
<script type="text/javascript">
var list = [{timestamp:new Date()}, {timestamp:new Date(1234567890)}, {timestamp:new Date(5678901234)}];
</script>
</head>
<body>
You can’t perform that action at this time.