diff options
author | Martin Lucina <mato@kotelna.sk> | 2011-03-28 10:39:51 +0200 |
---|---|---|
committer | Martin Lucina <martin@lucina.net> | 2012-01-23 08:53:37 +0100 |
commit | 3e20cb1b8a2b1ca222011df37334e5f4f88dd565 (patch) | |
tree | 4a753775186bc7f583f1ceb3f9aa675b6f110596 /src/msg_store.hpp | |
parent | 3f0085ddbef1a44b6bb7a0b23af497d56e0025fa (diff) | |
parent | e645fc2693acc796304498909786b7b47005b429 (diff) |
Imported Debian patch 2.1.3-1debian/2.1.3-1
Diffstat (limited to 'src/msg_store.hpp')
-rw-r--r-- | src/msg_store.hpp | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/src/msg_store.hpp b/src/msg_store.hpp deleted file mode 100644 index 765fc60..0000000 --- a/src/msg_store.hpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - Copyright (c) 2007-2010 iMatix Corporation - - This file is part of 0MQ. - - 0MQ is free software; you can redistribute it and/or modify it under - the terms of the Lesser GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - 0MQ is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - Lesser GNU General Public License for more details. - - You should have received a copy of the Lesser GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef __ZMQ_MSG_STORE_HPP_INCLUDED__ -#define __ZMQ_MSG_STORE_HPP_INCLUDED__ - -#include "../include/zmq.h" - -#include <string> -#include "stdint.hpp" - -namespace zmq -{ - - // This class implements a message store. Messages are retrieved from - // the store in the same order as they entered it. - - class msg_store_t - { - public: - - enum { default_block_size = 8192 }; - - // Creates message store. - msg_store_t (int64_t filesize_, size_t block_size_ = default_block_size); - - ~msg_store_t (); - - int init (); - - // Stores the message into the message store. The function - // returns false if the message store is full; true otherwise. - bool store (zmq_msg_t *msg_); - - // Fetches the oldest message from the message store. It is an error - // to call this function when the message store is empty. - void fetch (zmq_msg_t *msg_); - - void commit (); - - void rollback (); - - // Returns true if the message store is empty; false otherwise. - bool empty (); - - // Returns true if and only if the store is full. - bool full (); - - private: - - // Copies data from a memory buffer to the backing file. - // Wraps around when reaching maximum file size. - void copy_from_file (void *buffer_, size_t count_); - - // Copies data from the backing file to the memory buffer. - // Wraps around when reaching end-of-file. - void copy_to_file (const void *buffer_, size_t count_); - - // Returns the buffer space available. - int64_t buffer_space (); - - void fill_buf (char *buf, int64_t pos); - - void save_write_buf (); - - // File descriptor to the backing file. - int fd; - - // Name of the backing file. - std::string filename; - - // Maximum size of the backing file. - int64_t filesize; - - // File offset associated with the fd file descriptor. - int64_t file_pos; - - // File offset the next message will be stored at. - int64_t write_pos; - - // File offset the next message will be read from. - int64_t read_pos; - - int64_t commit_pos; - - size_t block_size; - - char *buf1; - char *buf2; - char *read_buf; - char *write_buf; - - int64_t write_buf_start_addr; - }; - -} - -#endif |