summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/habit-starts/habit.hpp
blob: 5c6f5e897f375c2820276181416342c447ca6115 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once

#include <stdlib.h> // int rand(); void srand(int seed);
#include <time.h> // int time(0);
#include <unistd.h> // usleep(unsigned int usecs)

__attribute__ ((visibility ("hidden"))) int __seed = (srand(time(0)), time(0));
#define habitdelay \
	static int thisdelay = (double(rand()) / RAND_MAX * 400000 + 200000); \
	usleep(thisdelay)

#undef self
#define ahabit(name, ...) \
	a(habit, name); \
	(name).fun((std::function<ref(ref)>) \
	[=](ref ctx) \
	{ \
		habitdelay; \
		ref self = name; \
		(void)self; \
		__VA_ARGS__ \
		return intellect::level1::concepts::nothing; \
	});