Page 1 of 1

CreateIpcQueue Questions

Posted: Tue Jul 06, 2021 7:14 am
by choochy2003
Is the documentation for the CreateIpcQueue API outdated? Specifically for maxThreadCount, from my testing it never generated more than the default 16 threads when using the default, but the documentation says that or only support 1 or unlimited.

Also, are the threads dynamically created as need? and are they destroyed again when they are no longer needed? In other words, is the thread pool dynamic.

Thanks!

Code: Select all

// Create an ipc queue.
// Please choose a unique ipc name to avoid conflicts with other programs.
// Only one ipc queue with the same name can be open at the same time.
// So if 2 programs try to create the same ipc queue, the second call will fail.
// You can specify how many threads may be created to handle incoming messages.
// If the order of the messages is crucial for you, set "maxThreadCount" to "1".
// In its current implementation "maxThreadCount" only supports "1" or unlimited.
// The parameter "maxQueueLen" is not yet implemented at all.
// The "context" is a simple pointer value that is forwarded to your callback.
function CreateIpcQueue (ipc            : pchar;
                         callback       : TIpcCallback;
                         context        : pointer = nil;
                         maxThreadCount : dword   = 16;
                         maxQueueLen    : dword   = $1000) : bool; stdcall;

Re: CreateIpcQueue Questions

Posted: Tue Jul 06, 2021 7:55 am
by madshi
Good question. Looking at my source code, there are 2 alternative IPC approaches, one based on pipes and one on LPC APIs. The newer LPC solution is used for newer OSs, the older one for older OSs. Anyway, when using the older pipe IPC approach, there's only either "maxThreadCount = 1" to limit threads to 1, or any other value gives you an unlimited number of threads. With the newer LPC based approach, the "maxThreadCount" parameter actually works properly. However, it's internally limited to max 64 threads.

Guess I need to update the documentation accordingly.

Re: CreateIpcQueue Questions

Posted: Tue Jul 06, 2021 8:02 am
by choochy2003
Thanks for that!

Also, are the threads dynamically created as need? and are they destroyed again when they are no longer needed? In other words, is the thread pool dynamic.

Re: CreateIpcQueue Questions

Posted: Tue Jul 06, 2021 8:59 am
by madshi
Yes, it should be fully dynamic.