Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
090e460d
Commit
090e460d
authored
Aug 31, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
naming cleanup: yarray->array
parent
f5acbb50
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
65 additions
and
94 deletions
+65
-94
Makefile.am
src/Makefile.am
+1
-2
array.hpp
src/array.hpp
+51
-15
ctx.hpp
src/ctx.hpp
+2
-2
fq.hpp
src/fq.hpp
+2
-2
lb.hpp
src/lb.hpp
+2
-2
pipe.hpp
src/pipe.hpp
+3
-3
pub.hpp
src/pub.hpp
+2
-2
socket_base.hpp
src/socket_base.hpp
+2
-2
yarray_item.hpp
src/yarray_item.hpp
+0
-64
No files found.
src/Makefile.am
View file @
090e460d
...
@@ -50,6 +50,7 @@ endif
...
@@ -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 = \
...
@@ -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
\
...
...
src/
y
array.hpp
→
src/array.hpp
View file @
090e460d
...
@@ -17,8 +17,8 @@
...
@@ -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_
Y
ARRAY_INCLUDED__
#ifndef __ZMQ_ARRAY_INCLUDED__
#define __ZMQ_
Y
ARRAY_INCLUDED__
#define __ZMQ_ARRAY_INCLUDED__
#include <vector>
#include <vector>
#include <algorithm>
#include <algorithm>
...
@@ -26,21 +26,57 @@
...
@@ -26,21 +26,57 @@
namespace
zmq
namespace
zmq
{
{
// Base class for objects stored in the array. Note that each object can
// be stored in at most one array.
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
// Fast array implementation with O(1) access to item, insertion and
// removal.
Ya
rray stores pointers rather than objects. The objects have
// removal.
A
rray stores pointers rather than objects. The objects have
// to be derived from
y
array_item_t class.
// to be derived from array_item_t class.
template
<
typename
T
>
class
y
array_t
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
y
array_t
()
inline
array_t
()
{
{
}
}
inline
~
y
array_t
()
inline
~
array_t
()
{
{
}
}
...
@@ -62,17 +98,17 @@ namespace zmq
...
@@ -62,17 +98,17 @@ namespace zmq
inline
void
push_back
(
T
*
item_
)
inline
void
push_back
(
T
*
item_
)
{
{
if
(
item_
)
if
(
item_
)
item_
->
set_
y
array_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_
y
array_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_
y
array_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
...
@@ -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_
y
array_index
(
index2_
);
items
[
index1_
]
->
set_array_index
(
index2_
);
if
(
items
[
index2_
])
if
(
items
[
index2_
])
items
[
index2_
]
->
set_
y
array_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
...
@@ -93,7 +129,7 @@ namespace zmq
inline
size_type
index
(
T
*
item_
)
inline
size_type
index
(
T
*
item_
)
{
{
return
(
size_type
)
item_
->
get_
y
array_index
();
return
(
size_type
)
item_
->
get_array_index
();
}
}
private
:
private
:
...
@@ -101,8 +137,8 @@ namespace zmq
...
@@ -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
y
array_t
&
);
array_t
(
const
array_t
&
);
void
operator
=
(
const
y
array_t
&
);
void
operator
=
(
const
array_t
&
);
};
};
}
}
...
...
src/ctx.hpp
View file @
090e460d
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#include "signaler.hpp"
#include "signaler.hpp"
#include "semaphore.hpp"
#include "semaphore.hpp"
#include "ypipe.hpp"
#include "ypipe.hpp"
#include "
y
array.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
...
@@ -79,7 +79,7 @@ namespace zmq
~
ctx_t
();
~
ctx_t
();
// Sockets belonging to this context.
// Sockets belonging to this context.
typedef
y
array_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.
...
...
src/fq.hpp
View file @
090e460d
...
@@ -20,7 +20,7 @@
...
@@ -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 "
y
array.hpp"
#include "array.hpp"
#include "pipe.hpp"
#include "pipe.hpp"
namespace
zmq
namespace
zmq
...
@@ -49,7 +49,7 @@ namespace zmq
...
@@ -49,7 +49,7 @@ namespace zmq
private
:
private
:
// Inbound pipes.
// Inbound pipes.
typedef
y
array_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
...
...
src/lb.hpp
View file @
090e460d
...
@@ -20,7 +20,7 @@
...
@@ -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 "
y
array.hpp"
#include "array.hpp"
#include "pipe.hpp"
#include "pipe.hpp"
namespace
zmq
namespace
zmq
...
@@ -47,7 +47,7 @@ namespace zmq
...
@@ -47,7 +47,7 @@ namespace zmq
private
:
private
:
// List of outbound pipes.
// List of outbound pipes.
typedef
y
array_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
...
...
src/pipe.hpp
View file @
090e460d
...
@@ -23,7 +23,7 @@
...
@@ -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
...
@@ -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
y
array_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
...
@@ -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
y
array_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
**
);
...
...
src/pub.hpp
View file @
090e460d
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
#define __ZMQ_PUB_HPP_INCLUDED__
#define __ZMQ_PUB_HPP_INCLUDED__
#include "socket_base.hpp"
#include "socket_base.hpp"
#include "
y
array.hpp"
#include "array.hpp"
#include "pipe.hpp"
#include "pipe.hpp"
namespace
zmq
namespace
zmq
...
@@ -54,7 +54,7 @@ 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
y
array_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
...
...
src/socket_base.hpp
View file @
090e460d
...
@@ -26,7 +26,7 @@
...
@@ -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
...
@@ -41,7 +41,7 @@ namespace zmq
class
socket_base_t
:
class
socket_base_t
:
public
own_t
,
public
own_t
,
public
y
array_item_t
public
array_item_t
{
{
public
:
public
:
...
...
src/yarray_item.hpp
deleted
100644 → 0
View file @
f5acbb50
/*
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment