Is there a queue implementation?

In fact, if what you want is a basic and easy to use fifo queue, slice provides all you need. queue := make([]int, 0) // Push to the queue queue = append(queue, 1) // Top (just get next element, don’t remove it) x = queue[0] // Discard top element queue = queue[1:] // Is empty … Read more

Named Pipes (FIFOs) on Unix with multiple readers

The O in FIFO means “out”. Once your data is “out”, it’s gone. 🙂 So naturally if another process comes along and someone else has already issued a read, the data isn’t going to be there twice. To accomplish what you suggest you should look into Unix domain sockets. Manpage here. You can write a … Read more

Which STL container should I use for a FIFO?

Since there are a myriad of answers, you might be confused, but to summarize: Use a std::queue. The reason for this is simple: it is a FIFO structure. You want FIFO, you use a std::queue. It makes your intent clear to anybody else, and even yourself. A std::list or std::deque does not. A list can … Read more

Create Named Pipe C++ Windows

You cannot create a named pipe by calling CreateFile(..). Have a look at the pipe examples of the MSDN. Since these examples are quite complex I’ve quickly written a VERY simple named pipe server and client. int main(void) { HANDLE hPipe; char buffer[1024]; DWORD dwRead; hPipe = CreateNamedPipe(TEXT(“\\\\.\\pipe\\Pipe”), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, // … Read more