Add AlgebraicChoppedVector as the future base for the event drivers FD map.

This commit is contained in:
Sönke Ludwig 2016-10-24 00:12:35 +02:00
parent 5cca0e863b
commit 2846637f95
3 changed files with 44 additions and 1 deletions

View file

@ -8,6 +8,8 @@ targetType "library"
libs "anl" platform="linux"
libs "ws2_32" platform="windows"
dependency "taggedalgebraic" version="~>0.10.4"
configuration "epoll" {
platforms "linux"
versions "EventcoreEpollDriver"

View file

@ -2,7 +2,7 @@ module eventcore.internal.consumablequeue;
/** FIFO queue with support for chunk-wise consumption.
*/
class ConsumableQueue(T)
final class ConsumableQueue(T)
{
@safe:
nothrow:

View file

@ -1,4 +1,8 @@
module eventcore.internal.utils;
import taggedalgebraic;
void print(ARGS...)(string str, ARGS args)
@trusted @nogc nothrow {
import std.format : formattedWrite;
@ -120,6 +124,43 @@ struct ChoppedVector(T, size_t CHUNK_SIZE = 16*64*1024/nextPOT(T.sizeof)) {
}
}
struct AlgebraicChoppedVector(TCommon, TSpecific...)
{
import std.conv : to;
import std.meta : AliasSeq;
union U { mixin fields!0; }
alias FieldType = TaggedAlgebraic!U;
static struct FullField {
TCommon common;
FieldType specific;
mixin(accessors());
}
ChoppedVector!(FullField) items;
alias items this;
private static string accessors()
{
import std.format : format;
string ret;
foreach (i, U; TSpecific)
ret ~= "@property ref TSpecific[%s] %s() nothrow @safe { return this.specific.get!(TSpecific[%s]); }\n"
.format(i, U.Handle.name, i);
return ret;
}
private mixin template fields(size_t i) {
static if (i < TSpecific.length) {
mixin("TSpecific["~i.to!string~"] "~TSpecific[i].Handle.name~";");
mixin fields!(i+1);
}
}
}
/** Efficient bit set of dynamic size.
*/
struct SmallIntegerSet(V : uint)