vibe.stream.multicast 0/13(0%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
330
340
350
360
370
380
390
400
410
420
430
440
450
460
470
480
490
500
510
520
530
540
550
560
570
580
590
600
610
620
630
/** Multicasts an input stream to multiple output streams. Copyright: © 2014-2016 RejectedSoftware e.K. License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. Authors: Eric Cornelius */ module vibe.stream.multicast; import vibe.core.core; import vibe.core.stream; import std.exception; MulticastStream createMulticastStream(scope OutputStream[] outputs...) { return new MulticastStream(outputs, true); } class MulticastStream : OutputStream { private { OutputStream[] m_outputs; } deprecated("Use createMulticastStream instead.") this(OutputStream[] outputs ...) { this(outputs, true); } /// private this(scope OutputStream[] outputs, bool dummy) { // NOTE: investigate .dup dmd workaround m_outputs = outputs.dup; } void finalize() { flush(); } void flush() { foreach (output; m_outputs) output.flush(); } size_t write(in ubyte[] bytes, IOMode mode) { if (!m_outputs.length) return bytes.length; auto ret = m_outputs[0].write(bytes, mode); foreach (output; m_outputs[1 .. $]) output.write(bytes[0 .. ret]); return ret; } alias write = OutputStream.write; }