Help #9

Open
opened 2019-01-11 13:16:49 +00:00 by JernejL · 4 comments
JernejL commented 2019-01-11 13:16:49 +00:00 (Migrated from github.com)

I need a bit help with the library, i'd like to pass arbitrary length of data / strings among threads (single producer single consumer), what approach can i use for this?

Can i just make a TPasMPBoundedQueue of pointers, which are memorystream instances allocated in one thread and process & free them in the other thread, or what would be the most efficient way?

I need a bit help with the library, i'd like to pass arbitrary length of data / strings among threads (single producer single consumer), what approach can i use for this? Can i just make a TPasMPBoundedQueue of pointers, which are memorystream instances allocated in one thread and process & free them in the other thread, or what would be the most efficient way?
BeRo1985 commented 2019-01-11 15:18:33 +00:00 (Migrated from github.com)

just use for example TPasMPBoundedQueue<string/DynamicArray> if you're
using modern object pascal with generics. or
use TPasMPSingleProducerSingleConsumerRingBuffer or
even TPasMPSingleProducerSingleConsumerBoundedQueue or
even TPasMPSingleProducerSingleConsumerBoundedQueue. Many roads lead to
Rome in this case.

On Fri, Jan 11, 2019 at 2:16 PM Jernej L. notifications@github.com wrote:

I need a bit help with the library, i'd like to pass arbitrary length of
data / strings among threads (single producer single consumer), what
approach can i use for this?

Can i just make a TPasMPBoundedQueue of pointers, which are memorystream
instances allocated in one thread and process & free them in the other
thread, or what would be the most efficient way?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/BeRo1985/pasmp/issues/9, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAaLP_JlVv81z3efYaBcS9pZNZ9YSVtrks5vCI7BgaJpZM4Z7cJp
.

just use for example TPasMPBoundedQueue<string/DynamicArray> if you're using modern object pascal with generics. or use TPasMPSingleProducerSingleConsumerRingBuffer or even TPasMPSingleProducerSingleConsumerBoundedQueue or even TPasMPSingleProducerSingleConsumerBoundedQueue<T>. Many roads lead to Rome in this case. On Fri, Jan 11, 2019 at 2:16 PM Jernej L. <notifications@github.com> wrote: > I need a bit help with the library, i'd like to pass arbitrary length of > data / strings among threads (single producer single consumer), what > approach can i use for this? > > Can i just make a TPasMPBoundedQueue of pointers, which are memorystream > instances allocated in one thread and process & free them in the other > thread, or what would be the most efficient way? > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > <https://github.com/BeRo1985/pasmp/issues/9>, or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAaLP_JlVv81z3efYaBcS9pZNZ9YSVtrks5vCI7BgaJpZM4Z7cJp> > . >
JernejL commented 2019-01-15 10:47:39 +00:00 (Migrated from github.com)

TPasMPSingleProducerSingleConsumerRingBuffer looks most promising, however the buffer size is always constant - would it be safe to pass a class instance pointer on a queue to another thread, and free it in another thread (to be used purely for messaging - passing over network packet data)?

TPasMPSingleProducerSingleConsumerRingBuffer looks most promising, however the buffer size is always constant - would it be safe to pass a class instance pointer on a queue to another thread, and free it in another thread (to be used purely for messaging - passing over network packet data)?
JernejL commented 2019-01-22 14:04:07 +00:00 (Migrated from github.com)

I've picked TPasMPUnboundedQueue and am pushing up memorystream instances created with param (sizeof(Tmemorystream))

It works great, althru encapsulating each call and write parameters to stream, and then read to call again is a bit annoying, i'd wish pascal had better RTTI to enable arbitrary method calls & parameter processing in some friendly manner..

I've picked TPasMPUnboundedQueue and am pushing up memorystream instances created with param (sizeof(Tmemorystream)) It works great, althru encapsulating each call and write parameters to stream, and then read to call again is a bit annoying, i'd wish pascal had better RTTI to enable arbitrary method calls & parameter processing in some friendly manner..
JernejL commented 2019-03-19 08:01:30 +00:00 (Migrated from github.com)

I'm now also using TPasMPUnboundedQueue to pass data to / from networking thread (enet), it has done wonders for responsivness of the whole game. In the past i would probably write some huge mess to achieve this and probably use some awkward type of locking.. Your libraries are truly one of more helpful projects on the internet.

I'd suggest you put in wiki a comparison table, of which c++ rtl elements can be mapped, this would make porting code much easier too, for example TPasMPUnboundedQueue is probably an equivalent of c++ queue.

I'm now also using TPasMPUnboundedQueue to pass data to / from networking thread (enet), it has done wonders for responsivness of the whole game. In the past i would probably write some huge mess to achieve this and probably use some awkward type of locking.. Your libraries are truly one of more helpful projects on the internet. I'd suggest you put in wiki a comparison table, of which c++ rtl elements can be mapped, this would make porting code much easier too, for example TPasMPUnboundedQueue is probably an equivalent of c++ queue.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
BeRo1985/pasmp#9
No description provided.