BeRo1985 / pasmp

PasMP - a parallel-processing/multi-processing library for Object Pascal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help

JernejL opened this issue · comments

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?

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.