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.transport;
|
||||
import tanya.async.watcher;
|
||||
import tanya.container.vector;
|
||||
import tanya.container.array;
|
||||
import tanya.memory;
|
||||
import tanya.memory.mmappool;
|
||||
import tanya.network.socket;
|
||||
@ -37,7 +37,7 @@ extern (C) nothrow @nogc
|
||||
final class EpollLoop : SelectorLoop
|
||||
{
|
||||
protected int fd;
|
||||
private Vector!epoll_event events;
|
||||
private Array!epoll_event events;
|
||||
|
||||
/**
|
||||
* Initializes the loop.
|
||||
@ -49,7 +49,7 @@ final class EpollLoop : SelectorLoop
|
||||
throw defaultAllocator.make!BadLoopException("epoll initialization failed");
|
||||
}
|
||||
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.transport;
|
||||
import tanya.async.watcher;
|
||||
import tanya.container.vector;
|
||||
import tanya.container.array;
|
||||
import tanya.memory;
|
||||
import tanya.memory.mmappool;
|
||||
import tanya.network.socket;
|
||||
@ -116,8 +116,8 @@ extern(C) int kevent(int kq, const kevent_t *changelist, int nchanges,
|
||||
final class KqueueLoop : SelectorLoop
|
||||
{
|
||||
protected int fd;
|
||||
private Vector!kevent_t events;
|
||||
private Vector!kevent_t changes;
|
||||
private Array!kevent_t events;
|
||||
private Array!kevent_t changes;
|
||||
private size_t changeCount;
|
||||
|
||||
/**
|
||||
@ -139,8 +139,8 @@ final class KqueueLoop : SelectorLoop
|
||||
throw make!BadLoopException(defaultAllocator,
|
||||
"kqueue initialization failed");
|
||||
}
|
||||
events = Vector!kevent_t(64, MmapPool.instance);
|
||||
changes = Vector!kevent_t(64, MmapPool.instance);
|
||||
events = Array!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.watcher;
|
||||
import tanya.container.buffer;
|
||||
import tanya.container.vector;
|
||||
import tanya.container.array;
|
||||
import tanya.memory;
|
||||
import tanya.memory.mmappool;
|
||||
import tanya.network.socket;
|
||||
@ -78,7 +78,8 @@ package class StreamTransport : SocketWatcher, DuplexTransport, SocketTransport
|
||||
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
|
||||
{
|
||||
assert(socket !is null);
|
||||
@ -133,7 +134,9 @@ package class StreamTransport : SocketWatcher, DuplexTransport, SocketTransport
|
||||
void close() @nogc
|
||||
{
|
||||
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
|
||||
{
|
||||
/// Pending connections.
|
||||
protected Vector!SocketWatcher connections;
|
||||
protected Array!SocketWatcher connections;
|
||||
|
||||
this() @nogc
|
||||
{
|
||||
super();
|
||||
connections = Vector!SocketWatcher(maxEvents, MmapPool.instance);
|
||||
connections = Array!SocketWatcher(maxEvents, MmapPool.instance);
|
||||
}
|
||||
|
||||
~this() @nogc
|
||||
{
|
||||
foreach (ref connection; connections)
|
||||
{
|
||||
// We want to free only the transports. ConnectionWatcher are created by the
|
||||
// user and should be freed by himself.
|
||||
// We want to free only the transports. ConnectionWatcher are
|
||||
// created by the user and should be freed by himself.
|
||||
if (cast(StreamTransport) connection !is null)
|
||||
{
|
||||
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;
|
||||
|
||||
public import tanya.container.array;
|
||||
public import tanya.container.buffer;
|
||||
public import tanya.container.list;
|
||||
public import tanya.container.string;
|
||||
public import tanya.container.vector;
|
||||
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.range;
|
||||
import std.traits;
|
||||
import tanya.container.vector;
|
||||
import tanya.container.array;
|
||||
import tanya.memory;
|
||||
|
||||
/**
|
||||
@ -1444,26 +1444,26 @@ struct Integer
|
||||
/**
|
||||
* Returns: Two's complement representation of the integer.
|
||||
*/
|
||||
Vector!ubyte toVector() const nothrow @safe @nogc
|
||||
out (vector)
|
||||
Array!ubyte toArray() const nothrow @safe @nogc
|
||||
out (array)
|
||||
{
|
||||
assert(vector.length == length);
|
||||
assert(array.length == length);
|
||||
}
|
||||
body
|
||||
{
|
||||
Vector!ubyte vector;
|
||||
Array!ubyte array;
|
||||
|
||||
if (this.size == 0)
|
||||
{
|
||||
return vector;
|
||||
return array;
|
||||
}
|
||||
const bc = countBits();
|
||||
const remainingBits = bc & 0x07;
|
||||
|
||||
vector.reserve(bc / 8);
|
||||
array.reserve(bc / 8);
|
||||
if (remainingBits == 0)
|
||||
{
|
||||
vector.insertBack(ubyte.init);
|
||||
array.insertBack(ubyte.init);
|
||||
|
||||
}
|
||||
|
||||
@ -1486,14 +1486,14 @@ struct Integer
|
||||
|
||||
do
|
||||
{
|
||||
vector.insertBack(cast(ubyte) (tmp.rep[0] & 0xff));
|
||||
array.insertBack(cast(ubyte) (tmp.rep[0] & 0xff));
|
||||
tmp >>= 8;
|
||||
}
|
||||
while (tmp != 0);
|
||||
|
||||
vector[].reverse();
|
||||
array[].reverse();
|
||||
|
||||
return vector;
|
||||
return array;
|
||||
}
|
||||
|
||||
///
|
||||
@ -1503,15 +1503,15 @@ struct Integer
|
||||
auto integer = Integer(0x66778899aabbddee);
|
||||
ubyte[8] expected = [ 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xdd, 0xee ];
|
||||
|
||||
auto vector = integer.toVector();
|
||||
assert(equal(vector[], expected[]));
|
||||
auto array = integer.toArray();
|
||||
assert(equal(array[], expected[]));
|
||||
}
|
||||
{
|
||||
auto integer = Integer(0x03);
|
||||
ubyte[1] expected = [ 0x03 ];
|
||||
|
||||
auto vector = integer.toVector();
|
||||
assert(equal(vector[], expected[]));
|
||||
auto array = integer.toArray();
|
||||
assert(equal(array[], expected[]));
|
||||
}
|
||||
{
|
||||
ubyte[63] expected = [
|
||||
@ -1526,8 +1526,8 @@ struct Integer
|
||||
];
|
||||
auto integer = Integer(Sign.positive, expected[]);
|
||||
|
||||
auto vector = integer.toVector();
|
||||
assert(equal(vector[], expected[]));
|
||||
auto array = integer.toArray();
|
||||
assert(equal(array[], expected[]));
|
||||
}
|
||||
{
|
||||
ubyte[14] expected = [
|
||||
@ -1536,8 +1536,8 @@ struct Integer
|
||||
];
|
||||
auto integer = Integer(Sign.positive, expected[]);
|
||||
|
||||
auto vector = integer.toVector();
|
||||
assert(equal(vector[], expected[]));
|
||||
auto array = integer.toArray();
|
||||
assert(equal(array[], expected[]));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user