Help #9
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
BeRo1985/pasmp#9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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?
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:
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)?
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'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.