Re: Avoiding allocation in broadcast server

2014-02-09 Thread Casper Færgemand
On Saturday, 8 February 2014 at 17:49:24 UTC, Kagamin wrote: Client reads from the client? And what does the server? Server reads from client and broadcasts to clients.

Re: Avoiding allocation in broadcast server

2014-02-08 Thread Kagamin
On Friday, 7 February 2014 at 22:04:31 UTC, Casper Færgemand wrote: Suppose I have a multi client broadcast server. One client sends a string, every client receives it. The client read thread reads the input from the client Client reads from the client? And what does the server? Is there a w

Re: Avoiding allocation in broadcast server

2014-02-08 Thread Casper Færgemand
On Saturday, 8 February 2014 at 11:15:31 UTC, Jakob Ovrum wrote: However, if this one allocation really is a problem, you might want to implement a simple free-list kind of allocator to allocate from. Say, pre-allocate N string buffers with M length and treat them as a free-list. If the free-li

Re: Avoiding allocation in broadcast server

2014-02-08 Thread Jakob Ovrum
On Friday, 7 February 2014 at 23:57:03 UTC, Stanislav Blinov wrote: To me it seems that you have to have at least one allocation per string received. To submit your string to another thread verbatim, you have to be able to guarantee that the buffer is immutable, which you cannot do because yo

Re: Avoiding allocation in broadcast server

2014-02-07 Thread Stanislav Blinov
To me it seems that you have to have at least one allocation per string received. To submit your string to another thread verbatim, you have to be able to guarantee that the buffer is immutable, which you cannot do because you can receive a new string at any given time (which would overwrite

Avoiding allocation in broadcast server

2014-02-07 Thread Casper Færgemand
Suppose I have a multi client broadcast server. One client sends a string, every client receives it. The client read thread reads the input from the client into a static byte array, makes a copy and casts it to a string, and passes it to the host thread, which relays it to all client write thre