mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-26 18:42:43 +01:00
naming cleanup: yarray->array
This commit is contained in:
@@ -50,6 +50,7 @@ endif
|
|||||||
nodist_libzmq_la_SOURCES = $(pgm_sources)
|
nodist_libzmq_la_SOURCES = $(pgm_sources)
|
||||||
|
|
||||||
libzmq_la_SOURCES = \
|
libzmq_la_SOURCES = \
|
||||||
|
array.hpp \
|
||||||
atomic_counter.hpp \
|
atomic_counter.hpp \
|
||||||
atomic_ptr.hpp \
|
atomic_ptr.hpp \
|
||||||
blob.hpp \
|
blob.hpp \
|
||||||
@@ -115,8 +116,6 @@ libzmq_la_SOURCES = \
|
|||||||
wire.hpp \
|
wire.hpp \
|
||||||
xrep.hpp \
|
xrep.hpp \
|
||||||
xreq.hpp \
|
xreq.hpp \
|
||||||
yarray.hpp \
|
|
||||||
yarray_item.hpp \
|
|
||||||
ypipe.hpp \
|
ypipe.hpp \
|
||||||
yqueue.hpp \
|
yqueue.hpp \
|
||||||
zmq_connecter.hpp \
|
zmq_connecter.hpp \
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __ZMQ_YARRAY_INCLUDED__
|
#ifndef __ZMQ_ARRAY_INCLUDED__
|
||||||
#define __ZMQ_YARRAY_INCLUDED__
|
#define __ZMQ_ARRAY_INCLUDED__
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -26,21 +26,57 @@
|
|||||||
namespace zmq
|
namespace zmq
|
||||||
{
|
{
|
||||||
|
|
||||||
// Fast array implementation with O(1) access to item, insertion and
|
// Base class for objects stored in the array. Note that each object can
|
||||||
// removal. Yarray stores pointers rather than objects. The objects have
|
// be stored in at most one array.
|
||||||
// to be derived from yarray_item_t class.
|
|
||||||
|
|
||||||
template <typename T> class yarray_t
|
class array_item_t
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
inline array_item_t () :
|
||||||
|
array_index (-1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// The destructor doesn't have to be virtual. It is mad virtual
|
||||||
|
// just to keep ICC and code checking tools from complaining.
|
||||||
|
inline virtual ~array_item_t ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void set_array_index (int index_)
|
||||||
|
{
|
||||||
|
array_index = index_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int get_array_index ()
|
||||||
|
{
|
||||||
|
return array_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
int array_index;
|
||||||
|
|
||||||
|
array_item_t (const array_item_t&);
|
||||||
|
void operator = (const array_item_t&);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Fast array implementation with O(1) access to item, insertion and
|
||||||
|
// removal. Array stores pointers rather than objects. The objects have
|
||||||
|
// to be derived from array_item_t class.
|
||||||
|
|
||||||
|
template <typename T> class array_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef typename std::vector <T*>::size_type size_type;
|
typedef typename std::vector <T*>::size_type size_type;
|
||||||
|
|
||||||
inline yarray_t ()
|
inline array_t ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ~yarray_t ()
|
inline ~array_t ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,17 +98,17 @@ namespace zmq
|
|||||||
inline void push_back (T *item_)
|
inline void push_back (T *item_)
|
||||||
{
|
{
|
||||||
if (item_)
|
if (item_)
|
||||||
item_->set_yarray_index (items.size ());
|
item_->set_array_index (items.size ());
|
||||||
items.push_back (item_);
|
items.push_back (item_);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void erase (T *item_) {
|
inline void erase (T *item_) {
|
||||||
erase (item_->get_yarray_index ());
|
erase (item_->get_array_index ());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void erase (size_type index_) {
|
inline void erase (size_type index_) {
|
||||||
if (items.back ())
|
if (items.back ())
|
||||||
items.back ()->set_yarray_index (index_);
|
items.back ()->set_array_index (index_);
|
||||||
items [index_] = items.back ();
|
items [index_] = items.back ();
|
||||||
items.pop_back ();
|
items.pop_back ();
|
||||||
}
|
}
|
||||||
@@ -80,9 +116,9 @@ namespace zmq
|
|||||||
inline void swap (size_type index1_, size_type index2_)
|
inline void swap (size_type index1_, size_type index2_)
|
||||||
{
|
{
|
||||||
if (items [index1_])
|
if (items [index1_])
|
||||||
items [index1_]->set_yarray_index (index2_);
|
items [index1_]->set_array_index (index2_);
|
||||||
if (items [index2_])
|
if (items [index2_])
|
||||||
items [index2_]->set_yarray_index (index1_);
|
items [index2_]->set_array_index (index1_);
|
||||||
std::swap (items [index1_], items [index2_]);
|
std::swap (items [index1_], items [index2_]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +129,7 @@ namespace zmq
|
|||||||
|
|
||||||
inline size_type index (T *item_)
|
inline size_type index (T *item_)
|
||||||
{
|
{
|
||||||
return (size_type) item_->get_yarray_index ();
|
return (size_type) item_->get_array_index ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -101,8 +137,8 @@ namespace zmq
|
|||||||
typedef std::vector <T*> items_t;
|
typedef std::vector <T*> items_t;
|
||||||
items_t items;
|
items_t items;
|
||||||
|
|
||||||
yarray_t (const yarray_t&);
|
array_t (const array_t&);
|
||||||
void operator = (const yarray_t&);
|
void operator = (const array_t&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
#include "signaler.hpp"
|
#include "signaler.hpp"
|
||||||
#include "semaphore.hpp"
|
#include "semaphore.hpp"
|
||||||
#include "ypipe.hpp"
|
#include "ypipe.hpp"
|
||||||
#include "yarray.hpp"
|
#include "array.hpp"
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "mutex.hpp"
|
#include "mutex.hpp"
|
||||||
#include "stdint.hpp"
|
#include "stdint.hpp"
|
||||||
@@ -79,7 +79,7 @@ namespace zmq
|
|||||||
~ctx_t ();
|
~ctx_t ();
|
||||||
|
|
||||||
// Sockets belonging to this context.
|
// Sockets belonging to this context.
|
||||||
typedef yarray_t <socket_base_t> sockets_t;
|
typedef array_t <socket_base_t> sockets_t;
|
||||||
sockets_t sockets;
|
sockets_t sockets;
|
||||||
|
|
||||||
// List of sockets that were already closed but not yet deallocated.
|
// List of sockets that were already closed but not yet deallocated.
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#ifndef __ZMQ_FQ_HPP_INCLUDED__
|
#ifndef __ZMQ_FQ_HPP_INCLUDED__
|
||||||
#define __ZMQ_FQ_HPP_INCLUDED__
|
#define __ZMQ_FQ_HPP_INCLUDED__
|
||||||
|
|
||||||
#include "yarray.hpp"
|
#include "array.hpp"
|
||||||
#include "pipe.hpp"
|
#include "pipe.hpp"
|
||||||
|
|
||||||
namespace zmq
|
namespace zmq
|
||||||
@@ -49,7 +49,7 @@ namespace zmq
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// Inbound pipes.
|
// Inbound pipes.
|
||||||
typedef yarray_t <reader_t> pipes_t;
|
typedef array_t <reader_t> pipes_t;
|
||||||
pipes_t pipes;
|
pipes_t pipes;
|
||||||
|
|
||||||
// Number of active pipes. All the active pipes are located at the
|
// Number of active pipes. All the active pipes are located at the
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#ifndef __ZMQ_LB_HPP_INCLUDED__
|
#ifndef __ZMQ_LB_HPP_INCLUDED__
|
||||||
#define __ZMQ_LB_HPP_INCLUDED__
|
#define __ZMQ_LB_HPP_INCLUDED__
|
||||||
|
|
||||||
#include "yarray.hpp"
|
#include "array.hpp"
|
||||||
#include "pipe.hpp"
|
#include "pipe.hpp"
|
||||||
|
|
||||||
namespace zmq
|
namespace zmq
|
||||||
@@ -47,7 +47,7 @@ namespace zmq
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// List of outbound pipes.
|
// List of outbound pipes.
|
||||||
typedef yarray_t <class writer_t> pipes_t;
|
typedef array_t <class writer_t> pipes_t;
|
||||||
pipes_t pipes;
|
pipes_t pipes;
|
||||||
|
|
||||||
// Number of active pipes. All the active pipes are located at the
|
// Number of active pipes. All the active pipes are located at the
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "../include/zmq.h"
|
#include "../include/zmq.h"
|
||||||
|
|
||||||
#include "stdint.hpp"
|
#include "stdint.hpp"
|
||||||
#include "yarray_item.hpp"
|
#include "array.hpp"
|
||||||
#include "ypipe.hpp"
|
#include "ypipe.hpp"
|
||||||
#include "swap.hpp"
|
#include "swap.hpp"
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
@@ -52,7 +52,7 @@ namespace zmq
|
|||||||
virtual void activated (class reader_t *pipe_) = 0;
|
virtual void activated (class reader_t *pipe_) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class reader_t : public object_t, public yarray_item_t
|
class reader_t : public object_t, public array_item_t
|
||||||
{
|
{
|
||||||
friend void zmq::create_pipe (object_t*, object_t*, uint64_t,
|
friend void zmq::create_pipe (object_t*, object_t*, uint64_t,
|
||||||
int64_t, reader_t**, writer_t**);
|
int64_t, reader_t**, writer_t**);
|
||||||
@@ -119,7 +119,7 @@ namespace zmq
|
|||||||
virtual void activated (class writer_t *pipe_) = 0;
|
virtual void activated (class writer_t *pipe_) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class writer_t : public object_t, public yarray_item_t
|
class writer_t : public object_t, public array_item_t
|
||||||
{
|
{
|
||||||
friend void zmq::create_pipe (object_t*, object_t*, uint64_t,
|
friend void zmq::create_pipe (object_t*, object_t*, uint64_t,
|
||||||
int64_t, reader_t**, writer_t**);
|
int64_t, reader_t**, writer_t**);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#define __ZMQ_PUB_HPP_INCLUDED__
|
#define __ZMQ_PUB_HPP_INCLUDED__
|
||||||
|
|
||||||
#include "socket_base.hpp"
|
#include "socket_base.hpp"
|
||||||
#include "yarray.hpp"
|
#include "array.hpp"
|
||||||
#include "pipe.hpp"
|
#include "pipe.hpp"
|
||||||
|
|
||||||
namespace zmq
|
namespace zmq
|
||||||
@@ -54,7 +54,7 @@ namespace zmq
|
|||||||
bool write (class writer_t *pipe_, zmq_msg_t *msg_);
|
bool write (class writer_t *pipe_, zmq_msg_t *msg_);
|
||||||
|
|
||||||
// Outbound pipes, i.e. those the socket is sending messages to.
|
// Outbound pipes, i.e. those the socket is sending messages to.
|
||||||
typedef yarray_t <class writer_t> pipes_t;
|
typedef array_t <class writer_t> pipes_t;
|
||||||
pipes_t pipes;
|
pipes_t pipes;
|
||||||
|
|
||||||
// Number of active pipes. All the active pipes are located at the
|
// Number of active pipes. All the active pipes are located at the
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include "../include/zmq.h"
|
#include "../include/zmq.h"
|
||||||
|
|
||||||
#include "own.hpp"
|
#include "own.hpp"
|
||||||
#include "yarray_item.hpp"
|
#include "array.hpp"
|
||||||
#include "mutex.hpp"
|
#include "mutex.hpp"
|
||||||
#include "options.hpp"
|
#include "options.hpp"
|
||||||
#include "stdint.hpp"
|
#include "stdint.hpp"
|
||||||
@@ -41,7 +41,7 @@ namespace zmq
|
|||||||
|
|
||||||
class socket_base_t :
|
class socket_base_t :
|
||||||
public own_t,
|
public own_t,
|
||||||
public yarray_item_t
|
public array_item_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -1,64 +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_YARRAY_ITEM_INCLUDED__
|
|
||||||
#define __ZMQ_YARRAY_ITEM_INCLUDED__
|
|
||||||
|
|
||||||
namespace zmq
|
|
||||||
{
|
|
||||||
|
|
||||||
// Base class for objects stored in yarray. Note that each object can
|
|
||||||
// be stored in at most one yarray.
|
|
||||||
|
|
||||||
class yarray_item_t
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
inline yarray_item_t () :
|
|
||||||
yarray_index (-1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// The destructor doesn't have to be virtual. It is mad virtual
|
|
||||||
// just to keep ICC and code checking tools from complaining.
|
|
||||||
inline virtual ~yarray_item_t ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void set_yarray_index (int index_)
|
|
||||||
{
|
|
||||||
yarray_index = index_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int get_yarray_index ()
|
|
||||||
{
|
|
||||||
return yarray_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
int yarray_index;
|
|
||||||
|
|
||||||
yarray_item_t (const yarray_item_t&);
|
|
||||||
void operator = (const yarray_item_t&);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user