1. As far as I know the number of ES clients is limited by the
system. Are there any constant which defines this number?
No.
I’m not actually sure if there is a fixed limit, but that shouldn’t matter because…
2. Can I create several ES clients in my daemon?
Yes.
However, doing this is questionable. You’d be better off having a single client and dynamically changing its settings.
3. Are there any limitations like a races in case of calling
es_subscribe
/ es_unsubscribe
in running client?
It’s hard to rule out any limitations but…
Can I manage subscription by a fly?
Yes.
4. Can I use posix mutexs in functions which are called inside the
block?
Yes, but that’s a bad idea. If you must use a mutex, an OS unfair lock (start here) is a much better idea.
Regardless of what you do, it’s critical that you not block that thread for a long period of time. So, using an unfair lock to serialise access to a fast data structure is fine, but don’t go calling malloc
within that lock.
5. Should we take care of signals while being in the block?
My general advice is that you not use signals for anything. There are much better IPC constructs on macOS.
6. Can we fork a new thread/process out of the block?
Probably, but see my response to question 4. This callback must be fast. If you’re creating a thread, or worse yet a process, from within this callback, you’re doing it wrong.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"