-2

How do I create a queue in c++ that will be allocated on a specific path?

I mounted ramfs on /mnt/ram/ which is a RAM folder rather than a disk , and would like the queue to be there, so the performance would be better than if the queue were allocated on the disk.

The queue is of the queue library of c++,that is:

#include <queue>
queue<string> requestsqueue;

Thanks

Alon_T
  • 1,430
  • 4
  • 26
  • 47
  • 1
    What sort of queue are you talking about? Because `std::deque` is in memory, rather than on the FS anywhere. If you're worried about performance, why put anything on the FS? – Mooing Duck Oct 23 '12 at 17:56
  • 4
    You need to accept more answers for people to help you out. – Coding Mash Oct 23 '12 at 17:57
  • Pretend we're idiots. What do you mean by "queue"? Where is the documentation for it? What command does one issue to create it? – Robᵩ Oct 23 '12 at 18:05
  • I'm curious -- what book, web page, or personal conversation led you to believe that `std::queue` exists in the filesystem? – Robᵩ Oct 23 '12 at 18:41

2 Answers2

2

How do I create a queue in c++ that will be allocated on a specific path?

You can't.

The queue is of the queue library of c++,that is:

#include <queue>
queue<string> requestsqueue;

The standard queue datastructure, std::queue, exists only in memory. It has no particular relationship to any disk file, nor to any path in the file system.

Robᵩ
  • 163,533
  • 20
  • 239
  • 308
0

You can create your file in /mnt/ram just like you would create your file anywhere else. The difference being the contents of ramfs are deleted when the system reboots.

You may also want to look into using tmpfs as its size can be limited so you don't use up all your memory and is backed by swap space so it can be paged out if it's not used for a while.

Here's a bit more info.

Dave Rager
  • 8,002
  • 3
  • 33
  • 52
  • this answer is misleading - std::queue doesnt go to disk, so discussions of manipulating any mount points doesnt really help – pm100 Oct 23 '12 at 23:04
  • @pm100 This answers the question that was asked. `std::queue` wasn't part of the question when I answered it. He didn't specify the data structure used for the queue and asked specifically about storing in a ram disk vs. allocating on a physical disk. – Dave Rager Oct 24 '12 at 02:43