Questions tagged [fifo]
Any structure in which the First object In is the First object Out. Synonyms include queue, and pipe.
fifo
1,126
questions
171
votes
15
answers
115k
views
Fixed size queue which automatically dequeues old values upon new enqueues
I'm using ConcurrentQueue<T> for a shared data structure which purpose is holding the last N objects passed to it (kind of history).
Assume we have a browser and we want to have the last 100 ...
111
votes
18
answers
145k
views
Is there a queue implementation?
Can anyone suggest Go container for simple and fast FIFO/queue, Go has 3 different containers: heap, list and vector. Which one is more suitable to implement a queue?
109
votes
8
answers
116k
views
Which STL container should I use for a FIFO?
Which STL container would fit my needs best? I basically have a 10 elements wide container in which I continually push_back new elements while pop_front ing the oldest element (about a million time).
...
76
votes
7
answers
186k
views
FIFO class in Java
I want to implement FIFO through a class in Java.
Does such a class already exist? If not, how can I implement my own?
NOTE
I found a class here http://www.dcache.org/manuals/cells/docs/api/dmg/...
68
votes
1
answer
31k
views
Why does a read-only open of a named pipe block?
I've noticed a couple of oddities when dealing with named pipes (FIFOs) under various flavors of UNIX (Linux, FreeBSD and MacOS X) using Python. The first, and perhaps most annoying is that attempts ...
50
votes
5
answers
36k
views
Named Pipes (FIFOs) on Unix with multiple readers
I have two programs, Writer and Reader.
I have a FIFO from Writer to Reader so when I write something to stdin in Writer, it gets printed out to stdout from Reader.
I tried doing this with TWO ...
47
votes
3
answers
100k
views
How to work with "FIFO" in C# .NET?
Is there a standard collection in .NET that implements a FIFO stack?
45
votes
10
answers
45k
views
Linux non-blocking fifo (on demand logging)
I like to log a programs output 'on demand'. Eg. the output is logged to the terminal, but another process can hook on the current output at any time.
The classic way would be:
myprogram 2>&...
44
votes
10
answers
6k
views
Is list better than vector when we need to store "the last n items"?
There are a lot of questions which suggest that one should always use a vector, but it seems to me that a list would be better for the scenario, where we need to store "the last n items"
For example, ...
33
votes
1
answer
23k
views
FIFO serial queue using GCD
I am trying to create a (network) synchronized array for the company I work for. While the networking part works fine, I have dwelled into an issue.
My wish was to create a new queue using ...
33
votes
6
answers
63k
views
Create a temporary FIFO (named pipe) in Python?
How can you create a temporary FIFO (named pipe) in Python? This should work:
import tempfile
temp_file_name = mktemp()
os.mkfifo(temp_file_name)
open(temp_file_name, os.O_WRONLY)
# ... some process,...
28
votes
1
answer
104k
views
Create Windows named pipe in C++
I am trying to create a simple communication between 2 processes in C++ (Windows) like FIFO in Linux.
This is my server:
int main()
{
HANDLE pipe = CreateFile(TEXT("\\\\.\\pipe\\Pipe"), ...
28
votes
2
answers
32k
views
How do I properly write to FIFOs in Python?
Something very strange is happening when I open FIFOs (named pipes) in Python for writing. Consider what happens when I try to open a FIFO for writing in a interactive interpreter:
>>> ...
26
votes
4
answers
32k
views
real time scheduling in Linux
This morning I read about Linux real time scheduling. As per the book 'Linux system programming by Robert Love', there are two main scheduling there. One is SCHED_FIFO, fifo and the second is SCHED_RR,...
23
votes
1
answer
44k
views
How do I perform a non-blocking fopen on a named pipe (mkfifo)?
If I have a program which creates and attempts to open a named pipe using mkfifo, how can I open a pipe for reading or writing without blocking?
Specifically, I'm writing a C program which can be run ...
22
votes
1
answer
26k
views
AWS SQS FIFO Queue: The queue should either have ContentBasedDeduplication enabled or MessageDeduplicationId provided explicitly?
When I try to add a message to my FIFO SQS using AWS CLI I get:
An error occurred (InvalidParameterValue) when calling the SendMessage operation: The queue should either have ContentBasedDeduplication ...
22
votes
2
answers
22k
views
How to read named FIFO non-blockingly?
I create a FIFO, and periodically open it in read-only and non-blockingly mode from a.py:
os.mkfifo(cs_cmd_fifo_file, 0777)
io = os.open(fifo, os.O_RDONLY | os.O_NONBLOCK)
buffer = os.read(io, ...
20
votes
4
answers
10k
views
Prevent FIFO from closing / reuse closed FIFO
Consider the following scenario:
a FIFO named test is created. In one terminal window (A) I run cat <test and in another (B) cat >test. It is now possible to write in window B and get the ...
20
votes
2
answers
14k
views
FIFO Map with limited elements
I need a HashMap or simpy a Map with a fixed number of elements (n) working like a FIFO queue.
So until the element number is <= n new elements are simply put in the map.
For element number > n ...
18
votes
2
answers
35k
views
FIFO behavior for Array.pop in javascript? [duplicate]
I want an Array method similar to Array.pop() that exhibits First In First Out behavior, instead of the native FILO behavior. Is there an easy way to do so?
Imagine a javascript console:
>> ...
17
votes
3
answers
14k
views
NSOperationQueue serial FIFO queue
Is it possible to use an NSoperationQueue object as a serial FIFO queue by setting its maxConcurrentOperationCount to 1?
I note that the docs state...
For a queue whose maximum number of ...
17
votes
3
answers
23k
views
Adding opencv processing to gstreamer application
I'm trying to do the following: receive video stream using gstreamer and process it with opencv. I've found few solutions, and one of them is to write video into (from gstreamer) fifo and then read it ...
16
votes
3
answers
7k
views
Is there a FIFO stream in Scala?
I'm looking for a FIFO stream in Scala, i.e., something that provides the functionality of
immutable.Stream (a stream that can be finite and memorizes the elements that have already been read)
...
16
votes
4
answers
26k
views
Reading a file in real-time using Node.js
I need to work out the best way to read data that is being written to a file, using node.js, in real time. Trouble is, Node is a fast moving ship which makes finding the best method for addressing a ...
14
votes
3
answers
14k
views
FIFO pipe is always readable in select()
In C pseudo-code:
while (1) {
fifo = open("fifo", O_RDONLY | O_NONBLOCK);
fd_set read;
FD_SET(fifo, &read);
select(nfds, &read, NULL, NULL, NULL);
}
The process sleeps as ...
14
votes
3
answers
40k
views
FIFO cache vs LRU cache
I'm really sorry for such simple question. I just want to be sure that I understand FIFO cache model correctly and I hope that someone will help me with that :) LRU cache deletes entry that was ...
14
votes
3
answers
26k
views
Write and read from a fifo from two different script
I have two bash script.
One script write in a fifo. The second one read from the fifo, but AFTER the first one end to write.
But something does not work. I do not understand where the problem is. ...
14
votes
1
answer
8k
views
Is it possible to upload a file with cURL from a pipe?
I mean POSTing a standard file upload form. Usual command line contains this switch in this case:
-F "[email protected]"
However when I try to feed a named pipe made by linux command "mkfifo", ...
13
votes
7
answers
23k
views
How implementation of java.util.queue uses LIFO?
In Java doc:
[...] Among the exceptions are priority queues, which order elements according to a supplied comparator, or the elements' natural ordering, and LIFO queues (or stacks) which order the ...
13
votes
5
answers
16k
views
Inter-process communication without FIFOs
Inside a BASH script we can have multiple processes running in background which intercommunicate using named pipes, FIFOs registered on the filesystem. An example of this could be:
#!/bin/bash
mkfifo ...
13
votes
4
answers
28k
views
LinkedHashMap LIFO or FIFO?
Is LinkedHashMap LIFO or FIFO in nature?
If my map is of the form:
map.put(1,"one");
map.put(2,"two");
what would be the order if I was to iterate on the map using keyset??
EDIT: I think I did ...
13
votes
1
answer
5k
views
What conditions result in an opened, nonblocking named pipe (fifo) being "unavailable" for reads?
Situation:
new_pipe = os.open(pipe_path, os.O_RDONLY | os.O_NONBLOCK) # pipe_path points to a FIFO
data = os.read(new_pipe, 1024)
The read occasionally raises errno -11: Resource temporarily ...
12
votes
1
answer
9k
views
When I try to open a fifo O_WRONLY I get a "No such device or address" error
In my code I create a fifo named "my_fifo", if I open it in O_WRONLY | O_NONBLOCK mode, open() returns a -1 and an error number of "No such device or address", on the other hand, if I open the fifo in ...
12
votes
2
answers
6k
views
Unix FIFO in go?
Is there any way to create a unix FIFO with Go language? There is no Mkfifo, nor Mknod in os package, though I expected named FIFOs are largely used in posix OS's. In fact, there is a function for ...
12
votes
1
answer
9k
views
Python code hangs while trying to open a named pipe for reading [duplicate]
I am trying to setup two way communication between a daemon and a client using named pipes. The code hangs while trying to open the named pipe used for input Why?
class comm(threading.Thread):
def ...
12
votes
3
answers
6k
views
forcing a program to flush its standard output when redirected
i have a closed source program that prints output to standard output. i need to parse the output. so i redirect the output to a fifo (from which i can read in the parent process that forks and execs ...
11
votes
5
answers
18k
views
Why implement Queues as Circular Array?
When implementing a FIFO like Queues, my instructor always advise us to represent it as a circular array and not in a regular array. Why?
Is it because in the latter, we would end up having garbage ...
11
votes
1
answer
43k
views
OSError: [Errno 11] Resource temporarily unavailable. What causes this?
Background
I have two python processes that need to communicate with each other. The comminication is handled by a class named Pipe. I made a seperate class for this because most of the information ...
10
votes
5
answers
9k
views
Can't write to FIFO file mouted via NFS
I'm trying to write to FIFO file locate on NFS mount and it blocks. What could be the problem?
My /etc/export:
/tmp/test/ 10.0.0.0/24(rw,no_root_squash,async)
ls /tmp/test on NFS server and client ...
10
votes
5
answers
11k
views
Does an optimistic lock-free FIFO queue implementation exist?
Is there any C++ implementation (source codes) of "optmistic approach to lock-free FIFO queues" algorithm?
10
votes
2
answers
23k
views
FIFO Implementation in Inventory using SQL
This is basically an inventory project which tracks the "Stock In" and "Stock Out" of items through Purchase and sales respectively.
The inventory system follows FIFO Method (the items which are ...
10
votes
2
answers
1k
views
Knitr: redirect chunk code output to terminal
I want to monitor some pretty lengthy parallelized computations embedded in a knitr file.
The computations rely on a package I have written, and the relevant function uses mclapply from the multicore ...
10
votes
2
answers
6k
views
Creating temporary named fifo in *nix system
I have some tasks requiring massive temporary named pipes to deal with.
Originally, I just simply think that generate random numbers, then append it as <number>.fifo be the name of named pipe.
...
10
votes
1
answer
6k
views
How to guarantee FIFO execution order in a ThreadPoolExecutor
I create a ThreadPoolExecutor with this line of code :
private ExecutorService executor = new ThreadPoolExecutor(5, 10, 120, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(20, true));
...
10
votes
1
answer
7k
views
Nonblocking/asynchronous fifo/named pipe in shell/filesystem?
Is there a way to create non blocking/asynchronous named pipe or something similar in shell? So that programs could place lines in it, those lines would stay in ram, and when some program could read ...
10
votes
1
answer
3k
views
Persistent connection in Bash script
I'm trying to create a persistent connection using bash. On terminal 1, I keep a netcat running as a server:
$ nc -vlkp 3000
Listening on [0.0.0.0] (family 0, port 3000)
On terminal 2, I create a ...
9
votes
2
answers
16k
views
Trying to understand Azure Service Bus Sessions
So I am trying to understand Azure service bus Session ID for creating FIFO in my queue.
The idea I have is pretty straight forward but I don't know if its the right way to thing when it comes to ...
9
votes
8
answers
3k
views
How to feed information to a Python daemon?
I have a Python daemon running on a Linux system.
I would like to feed information such as "Bob", "Alice", etc. and have the daemon print "Hello Bob." and "Hello Alice" to a file.
This has to be ...
9
votes
2
answers
10k
views
Implementing FIFO using LIFO
Looking at some algorithm exercices on the net, I found an interesting one :
How would you implement a FIFO using a LIFO ?
I tried myself but I ended up with only one solution : each time we want ...
9
votes
2
answers
37k
views
Write/Read to/from FIFO files - linux
I've been trying to wrap my head around FIFO, and came up with a simple program of server and client.
I'm not trying to do anything fancy, just to have one process that will play a role of 'server', ...