Skip to content

Commit

Permalink
Deprecate vibe.utils.array.FixedRingBuffer.
Browse files Browse the repository at this point in the history
Superseded by vibe.container.ringbuffer.RingBuffer.
  • Loading branch information
s-ludwig committed Feb 14, 2024
1 parent c6742fc commit f365293
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
8 changes: 5 additions & 3 deletions http/vibe/http/client.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public import vibe.core.net;
public import vibe.http.common;
public import vibe.inet.url;

import vibe.container.ringbuffer : RingBuffer;
import vibe.core.connectionpool;
import vibe.core.core;
import vibe.core.log;
Expand All @@ -22,7 +23,6 @@ import vibe.stream.tls;
import vibe.stream.operations;
import vibe.stream.wrapper : createConnectionProxyStream;
import vibe.stream.zlib;
import vibe.utils.array;
import vibe.utils.dictionarylist;
import vibe.container.internal.utilallocator;
import vibe.internal.freelistref;
Expand Down Expand Up @@ -207,7 +207,7 @@ auto connectHTTP(string host, ushort port = 0, bool use_tls = false, const(HTTPC
ret.connect(host, port, use_tls, sttngs);
return ret;
});
if (s_connections.full) s_connections.popFront();
if (s_connections.full) s_connections.removeFront();
s_connections.put(tuple(ckey, pool));
}

Expand All @@ -231,7 +231,7 @@ static ~this()
}

private struct ConnInfo { string host; string tlsPeerName; ushort port; bool useTLS; string proxyIP; ushort proxyPort; NetworkAddress bind_addr; }
private static vibe.utils.array.FixedRingBuffer!(Tuple!(ConnInfo, ConnectionPool!HTTPClient), 16) s_connections;
private static RingBuffer!(Tuple!(ConnInfo, ConnectionPool!HTTPClient), 16) s_connections;


/**************************************************************************************************/
Expand Down Expand Up @@ -787,6 +787,8 @@ private auto connectTCPWithTimeout(NetworkAddress addr, NetworkAddress bind_addr
Represents a HTTP client request (as sent to the server).
*/
final class HTTPClientRequest : HTTPRequest {
import vibe.internal.array : FixedAppender;

private {
InterfaceProxy!OutputStream m_bodyWriter;
FreeListRef!ChunkedOutputStream m_chunkedStream;
Expand Down
4 changes: 2 additions & 2 deletions stream/vibe/stream/taskpipe.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import core.sync.mutex;
import core.time;
import std.algorithm : min;
import std.exception;
import vibe.container.ringbuffer : RingBuffer;
import vibe.core.core;
import vibe.core.sync;
import vibe.utils.array;


/**
Expand Down Expand Up @@ -73,7 +73,7 @@ private final class TaskPipeImpl {
private {
Mutex m_mutex;
InterruptibleTaskCondition m_condition;
vibe.utils.array.FixedRingBuffer!ubyte m_buffer;
RingBuffer!ubyte m_buffer;
bool m_closed = false;
bool m_growWhenFull;
}
Expand Down
4 changes: 2 additions & 2 deletions stream/vibe/stream/zlib.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/
module vibe.stream.zlib;

import vibe.container.ringbuffer : RingBuffer;
import vibe.core.stream;
import vibe.utils.array;
import vibe.internal.freelistref;
import vibe.internal.interfaceproxy : InterfaceProxy, interfaceProxy;

Expand Down Expand Up @@ -220,7 +220,7 @@ class ZlibInputStream : InputStream {
private {
InterfaceProxy!InputStream m_in;
z_stream m_zstream;
FixedRingBuffer!(ubyte, 4096) m_outbuffer;
RingBuffer!(ubyte, 4096) m_outbuffer;
ubyte[1024] m_inbuffer;
bool m_finished = false;
ulong m_ninflated, n_read;
Expand Down
2 changes: 1 addition & 1 deletion utils/dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ description "Low level utility functionality"
targetType "library"
sourcePaths "."
importPaths "."
dependency "vibe-container" version=">=1.0.2 <2.0.0-0"
dependency "vibe-container" version=">=1.1.0 <2.0.0-0"
3 changes: 2 additions & 1 deletion utils/vibe/utils/array.d
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ struct FixedAppender(ArrayType : E[], size_t NELEM, E) {
/**
TODO: clear ring buffer fields upon removal (to run struct destructors, if T is a struct)
*/
deprecated("Use `vibe.container.ringbuffer.RingBuffer` instead.")
struct FixedRingBuffer(T, size_t N = 0, bool INITIALIZE = true) {
private {
static if( N > 0 ) {
Expand Down Expand Up @@ -505,7 +506,7 @@ struct FixedRingBuffer(T, size_t N = 0, bool INITIALIZE = true) {
}
}

unittest {
deprecated unittest {
import std.range : only;

static assert(isInputRange!(FixedRingBuffer!int) && isOutputRange!(FixedRingBuffer!int, int));
Expand Down

0 comments on commit f365293

Please sign in to comment.