diff options
| author | Eugen Wissner <belka@caraus.de> | 2017-01-12 09:09:33 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2017-01-12 09:09:33 +0100 |
| commit | 4de42ca227b667efcd113244e8b653d01dddfb75 (patch) | |
| tree | 4d8b5864886e89ae448f4347d314a65349b867fa /source | |
| parent | ab930657b6860b782e598ab7c627b85849b2d0db (diff) | |
| download | tanya-4de42ca227b667efcd113244e8b653d01dddfb75.tar.gz | |
Use only one queue for the async events
Diffstat (limited to 'source')
| -rw-r--r-- | source/tanya/async/event/epoll.d | 4 | ||||
| -rw-r--r-- | source/tanya/async/event/iocp.d | 6 | ||||
| -rw-r--r-- | source/tanya/async/event/kqueue.d | 2 | ||||
| -rw-r--r-- | source/tanya/async/event/selector.d | 4 | ||||
| -rw-r--r-- | source/tanya/async/iocp.d | 2 | ||||
| -rw-r--r-- | source/tanya/async/loop.d | 26 | ||||
| -rw-r--r-- | source/tanya/async/package.d | 2 | ||||
| -rw-r--r-- | source/tanya/async/protocol.d | 2 | ||||
| -rw-r--r-- | source/tanya/async/transport.d | 2 | ||||
| -rw-r--r-- | source/tanya/async/watcher.d | 5 |
10 files changed, 22 insertions, 33 deletions
diff --git a/source/tanya/async/event/epoll.d b/source/tanya/async/event/epoll.d index 5ffbf26..9f16c99 100644 --- a/source/tanya/async/event/epoll.d +++ b/source/tanya/async/event/epoll.d @@ -6,7 +6,7 @@ * Copyright: Eugene Wissner 2016.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
- * Authors: $(LINK2 mailto:belka@caraus.de, Eugene Wissner)
+ * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
*/
module tanya.async.event.epoll;
@@ -159,7 +159,7 @@ class EpollLoop : SelectorLoop }
else if (io.output.length)
{
- swapPendings.enqueue(io);
+ pendings.enqueue(io);
}
}
else if (events[i].events & EPOLLOUT)
diff --git a/source/tanya/async/event/iocp.d b/source/tanya/async/event/iocp.d index c86c309..b6522d9 100644 --- a/source/tanya/async/event/iocp.d +++ b/source/tanya/async/event/iocp.d @@ -6,7 +6,7 @@ * Copyright: Eugene Wissner 2016. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). - * Authors: $(LINK2 mailto:belka@caraus.de, Eugene Wissner) + * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) */ module tanya.async.event.iocp; @@ -222,7 +222,7 @@ class IOCPLoop : Loop reify(io, EventMask(Event.none), EventMask(Event.read, Event.write)); - swapPendings.enqueue(connection); + pendings.enqueue(connection); listener.beginAccept(overlapped); break; case OverlappedSocketEvent.read: @@ -264,7 +264,7 @@ class IOCPLoop : Loop { transport.socket.beginReceive(io.output[], overlapped); } - swapPendings.enqueue(io); + pendings.enqueue(io); } break; case OverlappedSocketEvent.write: diff --git a/source/tanya/async/event/kqueue.d b/source/tanya/async/event/kqueue.d index c0ce491..6e58178 100644 --- a/source/tanya/async/event/kqueue.d +++ b/source/tanya/async/event/kqueue.d @@ -271,7 +271,7 @@ class KqueueLoop : SelectorLoop } else if (io.output.length) { - swapPendings.enqueue(io); + pendings.enqueue(io); } } else if (events[i].filter == EVFILT_WRITE) diff --git a/source/tanya/async/event/selector.d b/source/tanya/async/event/selector.d index 10fcfa5..91c0c69 100644 --- a/source/tanya/async/event/selector.d +++ b/source/tanya/async/event/selector.d @@ -6,7 +6,7 @@ * Copyright: Eugene Wissner 2016. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). - * Authors: $(LINK2 mailto:belka@caraus.de, Eugene Wissner) + * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) */ module tanya.async.event.selector; @@ -253,7 +253,7 @@ abstract class SelectorLoop : Loop if (!connection.incoming.empty) { - swapPendings.enqueue(connection); + pendings.enqueue(connection); } } } diff --git a/source/tanya/async/iocp.d b/source/tanya/async/iocp.d index f915e36..9730262 100644 --- a/source/tanya/async/iocp.d +++ b/source/tanya/async/iocp.d @@ -6,7 +6,7 @@ * Copyright: Eugene Wissner 2016. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). - * Authors: $(LINK2 mailto:belka@caraus.de, Eugene Wissner) + * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) */ module tanya.async.iocp; diff --git a/source/tanya/async/loop.d b/source/tanya/async/loop.d index b024875..2d6210d 100644 --- a/source/tanya/async/loop.d +++ b/source/tanya/async/loop.d @@ -6,7 +6,7 @@ * Copyright: Eugene Wissner 2016.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
- * Authors: $(LINK2 mailto:belka@caraus.de, Eugene Wissner)
+ * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
*
* ---
* import tanya.async;
@@ -131,10 +131,7 @@ alias EventMask = BitFlags!Event; abstract class Loop
{
/// Pending watchers.
- protected Queue!Watcher* pendings;
-
- /// Ditto.
- protected Queue!Watcher* swapPendings;
+ protected Queue!Watcher pendings;
/**
* Returns: Maximal event count can be got at a time
@@ -151,8 +148,7 @@ abstract class Loop */
this() @nogc
{
- pendings = MmapPool.instance.make!(Queue!Watcher)(MmapPool.instance);
- swapPendings = MmapPool.instance.make!(Queue!Watcher)(MmapPool.instance);
+ pendings = Queue!Watcher(MmapPool.instance);
}
/**
@@ -160,17 +156,10 @@ abstract class Loop */
~this() @nogc
{
- foreach (w; *pendings)
- {
- MmapPool.instance.dispose(w);
- }
- MmapPool.instance.dispose(pendings);
-
- foreach (w; *swapPendings)
+ foreach (w; pendings)
{
MmapPool.instance.dispose(w);
}
- MmapPool.instance.dispose(swapPendings);
}
/**
@@ -184,11 +173,10 @@ abstract class Loop poll();
// Invoke pendings
- foreach (ref w; *swapPendings)
+ foreach (ref w; pendings)
{
w.invoke();
}
- swap(pendings, swapPendings);
}
while (!done_);
}
@@ -255,7 +243,7 @@ abstract class Loop inout @safe pure nothrow @nogc
{
// Don't block if we have to do.
- return swapPendings.empty ? blockTime_ : Duration.zero;
+ return pendings.empty ? blockTime_ : Duration.zero;
}
/**
@@ -285,7 +273,7 @@ abstract class Loop defaultAllocator.dispose(watcher.socket);
MmapPool.instance.dispose(watcher.transport);
watcher.exception = exception;
- swapPendings.enqueue(watcher);
+ pendings.enqueue(watcher);
}
/**
diff --git a/source/tanya/async/package.d b/source/tanya/async/package.d index 13c68ac..0c5a743 100644 --- a/source/tanya/async/package.d +++ b/source/tanya/async/package.d @@ -6,7 +6,7 @@ * Copyright: Eugene Wissner 2016.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
- * Authors: $(LINK2 mailto:belka@caraus.de, Eugene Wissner)
+ * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
*/
module tanya.async;
diff --git a/source/tanya/async/protocol.d b/source/tanya/async/protocol.d index 4851716..f8e9c09 100644 --- a/source/tanya/async/protocol.d +++ b/source/tanya/async/protocol.d @@ -6,7 +6,7 @@ * Copyright: Eugene Wissner 2016.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
- * Authors: $(LINK2 mailto:belka@caraus.de, Eugene Wissner)
+ * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
*/
module tanya.async.protocol;
diff --git a/source/tanya/async/transport.d b/source/tanya/async/transport.d index 2bc7929..d72d42d 100644 --- a/source/tanya/async/transport.d +++ b/source/tanya/async/transport.d @@ -6,7 +6,7 @@ * Copyright: Eugene Wissner 2016.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
- * Authors: $(LINK2 mailto:belka@caraus.de, Eugene Wissner)
+ * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
*/
module tanya.async.transport;
diff --git a/source/tanya/async/watcher.d b/source/tanya/async/watcher.d index 2bbccad..44b7a1d 100644 --- a/source/tanya/async/watcher.d +++ b/source/tanya/async/watcher.d @@ -6,7 +6,7 @@ * Copyright: Eugene Wissner 2016. * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * Mozilla Public License, v. 2.0). - * Authors: $(LINK2 mailto:belka@caraus.de, Eugene Wissner) + * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner) */ module tanya.async.watcher; @@ -61,6 +61,7 @@ class ConnectionWatcher : Watcher */ this(Socket socket) @nogc { + incoming = Queue!IOWatcher(MmapPool.instance); socket_ = socket; } @@ -233,7 +234,7 @@ class IOWatcher : ConnectionWatcher { if (output.length) { - protocol.received(output[0..$]); + protocol.received(output[0 .. $]); output.clear(); } else |
