stream

C#, is there such a thing as a “thread-safe” stream?

半城伤御伤魂 提交于 2020-03-11 20:09:51
问题 I am redirecting the output of a process into a streamreader which I read later. My problem is I am using multiple threads which SHOULD have separate instances of this stream. When I go to read this stream in, the threading fudges and starts executing oddly. Is there such a thing as making a thread-safe stream? EDIT: I put locks on the ReadToEnd on the streamreader, and the line where I did: reader = proc.StandardOutput; 回答1: There's a SyncrhonizedStream built into the framework, they just

Change InputStream by applying regex on it

北慕城南 提交于 2020-03-06 05:15:35
问题 I have an InputStream downloaded from the internet. And I need to apply regex on it - so that all occurrences of that regex would be changed to string, wich is provided. I need an InputStream as a return value since it should be forwarded to api. Basically, such signature would be the best: InputStream applyRegex(InputStream stream, Pattern pattern, String changeString){ ... } I have very basic knowledge of working with streams, please give an answer in method form, if it is possible. By the

Change InputStream by applying regex on it

∥☆過路亽.° 提交于 2020-03-06 05:14:51
问题 I have an InputStream downloaded from the internet. And I need to apply regex on it - so that all occurrences of that regex would be changed to string, wich is provided. I need an InputStream as a return value since it should be forwarded to api. Basically, such signature would be the best: InputStream applyRegex(InputStream stream, Pattern pattern, String changeString){ ... } I have very basic knowledge of working with streams, please give an answer in method form, if it is possible. By the

Dart stream .asBroadcastStream memory leak

与世无争的帅哥 提交于 2020-03-04 15:34:11
问题 In our Flutter application we have memory leaks and streams not being closed. We traced the source to code such as: Rx.combineLatest(...).asBroadcastStream() The result of RxDart .combineLatest() is a single-subscription stream. Adding .asBroadcastStream() makes the stream conveniently available to our various Flutter displays. However when these displays are closed the streams being combined are still active. 回答1: From the .asBroadcastStream() documentation: The returned stream will

Dart stream .asBroadcastStream memory leak

为君一笑 提交于 2020-03-04 15:34:01
问题 In our Flutter application we have memory leaks and streams not being closed. We traced the source to code such as: Rx.combineLatest(...).asBroadcastStream() The result of RxDart .combineLatest() is a single-subscription stream. Adding .asBroadcastStream() makes the stream conveniently available to our various Flutter displays. However when these displays are closed the streams being combined are still active. 回答1: From the .asBroadcastStream() documentation: The returned stream will

java8新特性(3)-Stream举例

丶灬走出姿态 提交于 2020-03-02 19:17:19
流(Stream) 可以定义为从一个源读取而来的支持聚集操作的一系列元素。这里说的源指的是集合或者数组,她们可以为源提供数据。流(Stream) 中数据的顺序和源保持一致。聚集操作或者批量操作允许我们很容易对流(Stream) 中的元素进行常见操作。 我将从下面几个方面讨论 Java 8 中的 流(Stream),如无特殊说明,下文中的流指的都是Stream。 流 vs. 集合 各种构建流对象的方式 转换流为集合 核心的流操作 中间操作 末端操作 短路操作 并行处理 在继续下文之前,有必要事先说明一下, Java 8 中的多数流操作只返回流对象。这有助于写出链式流操作,我们管这个叫管线。在这篇文章中我会多次使用这个术语,所以务必记住了哦。 流 vs. 集合 相信大家都在优酷上看过在线视频,当你开始观看视频时,文件的一小部分会首先下载到你的电脑中然后开始播放。在开始播放视频之前你并不需要把整个视频下载下来。我将尝试把这个概念与流关联起来。 在基本概念层面,集合与流的区别在于其中的元素是如何产生的。集合是存在于内存中的数据结构,其中保存了所有的元素对象,这些元素对象在加入到集合 中之前,必须已经构建好。流本质上不是数据结构,其中的元素对象是按需产生的。这带来了显著的好处,用户只能从流中取到他们真正需要的元素,这些元素也只 在用户真正需要的时候被生产出来。这看起来是一种生产者

Delphi stream panel to file

这一生的挚爱 提交于 2020-03-02 07:35:46
问题 today I've a question about streaming a part of a form to a file. In this example i use a Tmemo instead of file in order to see the stream. here is my form: The panel on the right top of the form has some controls, like label, edit and so on. with the "Save panel" butto I save the panel on a TStream: Here the code: procedure TfrmMain.btnSaveClick(Sender: TObject); var idx: Integer; MemStr: TStream; begin MemStr := TMemoryStream.Create; PanelStr := TMemoryStream.Create; try for idx := 0 to

looking for a MemoryStream in C++

北慕城南 提交于 2020-03-01 23:13:58
问题 In the wonderful world of C# i can create a memory stream without specifying its size, write into it and then just take the underlying buffer. How can i do the same in c++? basicly i need to do: memory_stream ms(GROW_AS_MUCH_AS_YOU_LIKE); ms << someLargeObjects << someSmallObjects << someObjectsWhosSizeIDontKnow; unsigned char* buffer = ms.GetBuffer(); int bufferSize = ms.GetBufferSize(); rawNetworkSocket.Send(buffer, bufferSize); By the way I have boost in my project though I'm not all that

Fill a nested structure with values from a linear supply stream

微笑、不失礼 提交于 2020-02-28 18:46:07
问题 I got stuck in the resolution of the next problem: Imagine we have an array structure, any structure, but for this example let's use: [ [ [1, 2], [3, 4], [5, 6] ], [ 7, 8, 9, 10 ] ] For convenience, I transform this structure into a flat array like: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] Imagine that after certain operations our array looks like this: [ 1, 2, 3, 4, 12515, 25125, 12512, 8, 9, 10] NOTE: those values are a result of some operation, I just want to point out that is independent from

Converting stream encryption method from .NET to RT

折月煮酒 提交于 2020-02-25 04:32:47
问题 I'm trying to convert Encryption/Decryption methods from managed .NET to WinRT version for use in Windows Store app. The managed .NET encryption methods are already used largely in production, so the assumption is they work correctly. This is the managed .NET encryption method: public static byte[] iv = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }; public static void EncryptFile(string sInputFilename, string sOutputFilename, string sKey) { FileStream fsInput = null; FileStream fsOutput = null;