I'm working on a library to create IPC based on UNIX socket on Linux. The goal is to hide the IPC logic in a library and I use a thread which handles the socket for external communication.
Since I want to mux/demux data coming from outside to multiple reader/writer internal threads, I'm using pipes to communicate between this management thread and the others.
Now, I would like to manage kind of QoS as well and thus, would like to block some user threads in write direction when I know there is no space left of the other side (the other IPC process reading data from me too slowly for example).
To notify a internal user thread there is no place left for sending data (in its "virtual channel"), I would like to mark its sending pipe as non writable then this thread can use for example select on this sending pipe file descriptor.
My question is then: is there a way to mark a pipe write file descriptor as non writable even if there is still free place in its internal buffer and mark it as writable again when my management thread decides it ? Keeping in mind the write status event should be able to be managed by functions like select, poll, etc.
P.S.: I know there is a lot of libraries which could help me doing the same job more easily like ZeroMQ or nanomsg but they are far too heavy for what I would like to achieve.