Skip to content

Instantly share code, notes, and snippets.

View stepancheg's full-sized avatar

Stepan Koltsov stepancheg

View GitHub Profile
extern mod std;
use core::comm;
use std::time;
fn to_us(ts: &time::Timespec) -> u64 {
ts.sec * 1000000 as u64 + ((ts.nsec / 1000) as u64)
}
// реализация пользовательского актёра
class CounterActor implement Runnable {
// ...
// очередь входящих сообщений
// очередей может быть несколько
private final LockFreeStackWithSize<BigInteger> workQueue =
new LockFreeStackWithSize<BigInteger>();
struct Foo;
struct Bar {
Foo foo;
};
struct Foo {
};
int main() {
.file "./qw.c"
.text
.globl foo
.align 16, 0x90
.type foo,@function
foo: # @foo
.cfi_startproc
# BB#0: # %entry
movl $17, %eax
xchgq %rax, (%rdi)
.file "qw.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
movq $17, (%rdi)
mfence
void foo(long* x, long* y) {
__atomic_store_n(x, 17l, __ATOMIC_SEQ_CST);
__atomic_store_n(y, 19l, __ATOMIC_SEQ_CST);
}
void bar(long *x, long* y) {
*x = 21l;
*y = 23l;
}

В программах, говорят, 90% времени работает 10% кода. И оптимизировать надо эти 10% кода, а оставшиеся 90% кода писать так, чтобы было удобно сопровождать.

Примерно так же надо относиться к городу. Духовность на 90% пространства города надо сохранять, а 10% самых используемых пространств улучшить — переименовать станции, упростить навигацию, сделать удобным.

Карта метро — это 0,0000001 духовности города, зато она доставляет

struct aaa {
const int x;
aaa(): x(1) {}
};
int main() {
aaa a;
aaa b;
b = a; // compilation error
struct aaa {
const int x;
aaa(): x(1) {}
};
int main() {
aaa a;
aaa b;
b = a; // compilation error
#define UNW_LOCAL_ONLY
#include <libunwind.h>
#include <signal.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>