Rename Vector to Array
For consistency with Phobos.
This commit is contained in:
parent
58664570f9
commit
8c42cbfd63
@ -18,7 +18,7 @@ import tanya.async.event.selector;
|
|||||||
import tanya.async.loop;
|
import tanya.async.loop;
|
||||||
import tanya.async.transport;
|
import tanya.async.transport;
|
||||||
import tanya.async.watcher;
|
import tanya.async.watcher;
|
||||||
import tanya.container.vector;
|
import tanya.container.array;
|
||||||
import tanya.memory;
|
import tanya.memory;
|
||||||
import tanya.memory.mmappool;
|
import tanya.memory.mmappool;
|
||||||
import tanya.network.socket;
|
import tanya.network.socket;
|
||||||
@ -37,7 +37,7 @@ extern (C) nothrow @nogc
|
|||||||
final class EpollLoop : SelectorLoop
|
final class EpollLoop : SelectorLoop
|
||||||
{
|
{
|
||||||
protected int fd;
|
protected int fd;
|
||||||
private Vector!epoll_event events;
|
private Array!epoll_event events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the loop.
|
* Initializes the loop.
|
||||||
@ -49,7 +49,7 @@ final class EpollLoop : SelectorLoop
|
|||||||
throw defaultAllocator.make!BadLoopException("epoll initialization failed");
|
throw defaultAllocator.make!BadLoopException("epoll initialization failed");
|
||||||
}
|
}
|
||||||
super();
|
super();
|
||||||
events = Vector!epoll_event(maxEvents, MmapPool.instance);
|
events = Array!epoll_event(maxEvents, MmapPool.instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +50,7 @@ import tanya.async.event.selector;
|
|||||||
import tanya.async.loop;
|
import tanya.async.loop;
|
||||||
import tanya.async.transport;
|
import tanya.async.transport;
|
||||||
import tanya.async.watcher;
|
import tanya.async.watcher;
|
||||||
import tanya.container.vector;
|
import tanya.container.array;
|
||||||
import tanya.memory;
|
import tanya.memory;
|
||||||
import tanya.memory.mmappool;
|
import tanya.memory.mmappool;
|
||||||
import tanya.network.socket;
|
import tanya.network.socket;
|
||||||
@ -116,8 +116,8 @@ extern(C) int kevent(int kq, const kevent_t *changelist, int nchanges,
|
|||||||
final class KqueueLoop : SelectorLoop
|
final class KqueueLoop : SelectorLoop
|
||||||
{
|
{
|
||||||
protected int fd;
|
protected int fd;
|
||||||
private Vector!kevent_t events;
|
private Array!kevent_t events;
|
||||||
private Vector!kevent_t changes;
|
private Array!kevent_t changes;
|
||||||
private size_t changeCount;
|
private size_t changeCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,8 +139,8 @@ final class KqueueLoop : SelectorLoop
|
|||||||
throw make!BadLoopException(defaultAllocator,
|
throw make!BadLoopException(defaultAllocator,
|
||||||
"kqueue initialization failed");
|
"kqueue initialization failed");
|
||||||
}
|
}
|
||||||
events = Vector!kevent_t(64, MmapPool.instance);
|
events = Array!kevent_t(64, MmapPool.instance);
|
||||||
changes = Vector!kevent_t(64, MmapPool.instance);
|
changes = Array!kevent_t(64, MmapPool.instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,7 @@ import tanya.async.protocol;
|
|||||||
import tanya.async.transport;
|
import tanya.async.transport;
|
||||||
import tanya.async.watcher;
|
import tanya.async.watcher;
|
||||||
import tanya.container.buffer;
|
import tanya.container.buffer;
|
||||||
import tanya.container.vector;
|
import tanya.container.array;
|
||||||
import tanya.memory;
|
import tanya.memory;
|
||||||
import tanya.memory.mmappool;
|
import tanya.memory.mmappool;
|
||||||
import tanya.network.socket;
|
import tanya.network.socket;
|
||||||
@ -78,7 +78,8 @@ package class StreamTransport : SocketWatcher, DuplexTransport, SocketTransport
|
|||||||
return cast(ConnectedSocket) socket_;
|
return cast(ConnectedSocket) socket_;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @property void socket(ConnectedSocket socket) pure nothrow @safe @nogc
|
private @property void socket(ConnectedSocket socket)
|
||||||
|
pure nothrow @safe @nogc
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(socket !is null);
|
assert(socket !is null);
|
||||||
@ -133,7 +134,9 @@ package class StreamTransport : SocketWatcher, DuplexTransport, SocketTransport
|
|||||||
void close() @nogc
|
void close() @nogc
|
||||||
{
|
{
|
||||||
closing = true;
|
closing = true;
|
||||||
loop.reify(this, EventMask(Event.read, Event.write), EventMask(Event.write));
|
loop.reify(this,
|
||||||
|
EventMask(Event.read, Event.write),
|
||||||
|
EventMask(Event.write));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -205,20 +208,20 @@ package class StreamTransport : SocketWatcher, DuplexTransport, SocketTransport
|
|||||||
abstract class SelectorLoop : Loop
|
abstract class SelectorLoop : Loop
|
||||||
{
|
{
|
||||||
/// Pending connections.
|
/// Pending connections.
|
||||||
protected Vector!SocketWatcher connections;
|
protected Array!SocketWatcher connections;
|
||||||
|
|
||||||
this() @nogc
|
this() @nogc
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
connections = Vector!SocketWatcher(maxEvents, MmapPool.instance);
|
connections = Array!SocketWatcher(maxEvents, MmapPool.instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
~this() @nogc
|
~this() @nogc
|
||||||
{
|
{
|
||||||
foreach (ref connection; connections)
|
foreach (ref connection; connections)
|
||||||
{
|
{
|
||||||
// We want to free only the transports. ConnectionWatcher are created by the
|
// We want to free only the transports. ConnectionWatcher are
|
||||||
// user and should be freed by himself.
|
// created by the user and should be freed by himself.
|
||||||
if (cast(StreamTransport) connection !is null)
|
if (cast(StreamTransport) connection !is null)
|
||||||
{
|
{
|
||||||
MmapPool.instance.dispose(connection);
|
MmapPool.instance.dispose(connection);
|
||||||
|
1646
source/tanya/container/array.d
Normal file
1646
source/tanya/container/array.d
Normal file
File diff suppressed because it is too large
Load Diff
@ -12,8 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
module tanya.container;
|
module tanya.container;
|
||||||
|
|
||||||
|
public import tanya.container.array;
|
||||||
public import tanya.container.buffer;
|
public import tanya.container.buffer;
|
||||||
public import tanya.container.list;
|
public import tanya.container.list;
|
||||||
public import tanya.container.string;
|
public import tanya.container.string;
|
||||||
public import tanya.container.vector;
|
|
||||||
public import tanya.container.queue;
|
public import tanya.container.queue;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,7 @@ import std.algorithm;
|
|||||||
import std.ascii;
|
import std.ascii;
|
||||||
import std.range;
|
import std.range;
|
||||||
import std.traits;
|
import std.traits;
|
||||||
import tanya.container.vector;
|
import tanya.container.array;
|
||||||
import tanya.memory;
|
import tanya.memory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1444,26 +1444,26 @@ struct Integer
|
|||||||
/**
|
/**
|
||||||
* Returns: Two's complement representation of the integer.
|
* Returns: Two's complement representation of the integer.
|
||||||
*/
|
*/
|
||||||
Vector!ubyte toVector() const nothrow @safe @nogc
|
Array!ubyte toArray() const nothrow @safe @nogc
|
||||||
out (vector)
|
out (array)
|
||||||
{
|
{
|
||||||
assert(vector.length == length);
|
assert(array.length == length);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
Vector!ubyte vector;
|
Array!ubyte array;
|
||||||
|
|
||||||
if (this.size == 0)
|
if (this.size == 0)
|
||||||
{
|
{
|
||||||
return vector;
|
return array;
|
||||||
}
|
}
|
||||||
const bc = countBits();
|
const bc = countBits();
|
||||||
const remainingBits = bc & 0x07;
|
const remainingBits = bc & 0x07;
|
||||||
|
|
||||||
vector.reserve(bc / 8);
|
array.reserve(bc / 8);
|
||||||
if (remainingBits == 0)
|
if (remainingBits == 0)
|
||||||
{
|
{
|
||||||
vector.insertBack(ubyte.init);
|
array.insertBack(ubyte.init);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1486,14 +1486,14 @@ struct Integer
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
vector.insertBack(cast(ubyte) (tmp.rep[0] & 0xff));
|
array.insertBack(cast(ubyte) (tmp.rep[0] & 0xff));
|
||||||
tmp >>= 8;
|
tmp >>= 8;
|
||||||
}
|
}
|
||||||
while (tmp != 0);
|
while (tmp != 0);
|
||||||
|
|
||||||
vector[].reverse();
|
array[].reverse();
|
||||||
|
|
||||||
return vector;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -1503,15 +1503,15 @@ struct Integer
|
|||||||
auto integer = Integer(0x66778899aabbddee);
|
auto integer = Integer(0x66778899aabbddee);
|
||||||
ubyte[8] expected = [ 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xdd, 0xee ];
|
ubyte[8] expected = [ 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xdd, 0xee ];
|
||||||
|
|
||||||
auto vector = integer.toVector();
|
auto array = integer.toArray();
|
||||||
assert(equal(vector[], expected[]));
|
assert(equal(array[], expected[]));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto integer = Integer(0x03);
|
auto integer = Integer(0x03);
|
||||||
ubyte[1] expected = [ 0x03 ];
|
ubyte[1] expected = [ 0x03 ];
|
||||||
|
|
||||||
auto vector = integer.toVector();
|
auto array = integer.toArray();
|
||||||
assert(equal(vector[], expected[]));
|
assert(equal(array[], expected[]));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ubyte[63] expected = [
|
ubyte[63] expected = [
|
||||||
@ -1526,8 +1526,8 @@ struct Integer
|
|||||||
];
|
];
|
||||||
auto integer = Integer(Sign.positive, expected[]);
|
auto integer = Integer(Sign.positive, expected[]);
|
||||||
|
|
||||||
auto vector = integer.toVector();
|
auto array = integer.toArray();
|
||||||
assert(equal(vector[], expected[]));
|
assert(equal(array[], expected[]));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ubyte[14] expected = [
|
ubyte[14] expected = [
|
||||||
@ -1536,8 +1536,8 @@ struct Integer
|
|||||||
];
|
];
|
||||||
auto integer = Integer(Sign.positive, expected[]);
|
auto integer = Integer(Sign.positive, expected[]);
|
||||||
|
|
||||||
auto vector = integer.toVector();
|
auto array = integer.toArray();
|
||||||
assert(equal(vector[], expected[]));
|
assert(equal(array[], expected[]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user