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
87a08e17
Commit
87a08e17
authored
May 03, 2014
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1006 from hurtonm/master
Remove i_properties interface
parents
c5cd92da
f2807d11
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
90 deletions
+43
-90
i_properties.hpp
src/i_properties.hpp
+0
-47
metadata.hpp
src/metadata.hpp
+2
-2
msg.cpp
src/msg.cpp
+23
-23
msg.hpp
src/msg.hpp
+13
-13
stream_engine.cpp
src/stream_engine.cpp
+1
-1
zmq.cpp
src/zmq.cpp
+4
-4
No files found.
src/i_properties.hpp
deleted
100644 → 0
View file @
c5cd92da
/*
Copyright (c) 2007-2014 Contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser 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
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ZMQ_I_PROPERTIES_HPP_INCLUDED__
#define __ZMQ_I_PROPERTIES_HPP_INCLUDED__
#include <string>
namespace
zmq
{
// Interface for accessing message properties.
// Implementers are supposed to use reference counting to
// manage object's lifetime.
struct
i_properties
{
virtual
~
i_properties
()
{}
// Returns pointer to property value or NULL if
// property not found.
virtual
const
char
*
get
(
const
std
::
string
&
property
)
const
=
0
;
virtual
void
add_ref
()
=
0
;
// Drop reference. Returns true iff the reference
// counter drops to zero.
virtual
bool
drop_ref
()
=
0
;
};
}
#endif
src/metadata.hpp
View file @
87a08e17
...
@@ -21,13 +21,13 @@
...
@@ -21,13 +21,13 @@
#define __ZMQ_METADATA_HPP_INCLUDED__
#define __ZMQ_METADATA_HPP_INCLUDED__
#include <map>
#include <map>
#include <string>
#include "atomic_counter.hpp"
#include "atomic_counter.hpp"
#include "i_properties.hpp"
namespace
zmq
namespace
zmq
{
{
class
metadata_t
:
public
i_properties
class
metadata_t
{
{
public
:
public
:
...
...
src/msg.cpp
View file @
87a08e17
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include "stdint.hpp"
#include "stdint.hpp"
#include "likely.hpp"
#include "likely.hpp"
#include "
i_properties
.hpp"
#include "
metadata
.hpp"
#include "err.hpp"
#include "err.hpp"
// Check whether the sizes of public representation of the message (zmq_msg_t)
// Check whether the sizes of public representation of the message (zmq_msg_t)
...
@@ -42,7 +42,7 @@ bool zmq::msg_t::check ()
...
@@ -42,7 +42,7 @@ bool zmq::msg_t::check ()
int
zmq
::
msg_t
::
init
()
int
zmq
::
msg_t
::
init
()
{
{
u
.
vsm
.
properties
=
NULL
;
u
.
vsm
.
metadata
=
NULL
;
u
.
vsm
.
type
=
type_vsm
;
u
.
vsm
.
type
=
type_vsm
;
u
.
vsm
.
flags
=
0
;
u
.
vsm
.
flags
=
0
;
u
.
vsm
.
size
=
0
;
u
.
vsm
.
size
=
0
;
...
@@ -54,13 +54,13 @@ int zmq::msg_t::init_size (size_t size_)
...
@@ -54,13 +54,13 @@ int zmq::msg_t::init_size (size_t size_)
{
{
file_desc
=
-
1
;
file_desc
=
-
1
;
if
(
size_
<=
max_vsm_size
)
{
if
(
size_
<=
max_vsm_size
)
{
u
.
vsm
.
properties
=
NULL
;
u
.
vsm
.
metadata
=
NULL
;
u
.
vsm
.
type
=
type_vsm
;
u
.
vsm
.
type
=
type_vsm
;
u
.
vsm
.
flags
=
0
;
u
.
vsm
.
flags
=
0
;
u
.
vsm
.
size
=
(
unsigned
char
)
size_
;
u
.
vsm
.
size
=
(
unsigned
char
)
size_
;
}
}
else
{
else
{
u
.
lmsg
.
properties
=
NULL
;
u
.
lmsg
.
metadata
=
NULL
;
u
.
lmsg
.
type
=
type_lmsg
;
u
.
lmsg
.
type
=
type_lmsg
;
u
.
lmsg
.
flags
=
0
;
u
.
lmsg
.
flags
=
0
;
u
.
lmsg
.
content
=
u
.
lmsg
.
content
=
...
@@ -90,14 +90,14 @@ int zmq::msg_t::init_data (void *data_, size_t size_, msg_free_fn *ffn_,
...
@@ -90,14 +90,14 @@ int zmq::msg_t::init_data (void *data_, size_t size_, msg_free_fn *ffn_,
// Initialize constant message if there's no need to deallocate
// Initialize constant message if there's no need to deallocate
if
(
ffn_
==
NULL
)
{
if
(
ffn_
==
NULL
)
{
u
.
cmsg
.
properties
=
NULL
;
u
.
cmsg
.
metadata
=
NULL
;
u
.
cmsg
.
type
=
type_cmsg
;
u
.
cmsg
.
type
=
type_cmsg
;
u
.
cmsg
.
flags
=
0
;
u
.
cmsg
.
flags
=
0
;
u
.
cmsg
.
data
=
data_
;
u
.
cmsg
.
data
=
data_
;
u
.
cmsg
.
size
=
size_
;
u
.
cmsg
.
size
=
size_
;
}
}
else
{
else
{
u
.
lmsg
.
properties
=
NULL
;
u
.
lmsg
.
metadata
=
NULL
;
u
.
lmsg
.
type
=
type_lmsg
;
u
.
lmsg
.
type
=
type_lmsg
;
u
.
lmsg
.
flags
=
0
;
u
.
lmsg
.
flags
=
0
;
u
.
lmsg
.
content
=
(
content_t
*
)
malloc
(
sizeof
(
content_t
));
u
.
lmsg
.
content
=
(
content_t
*
)
malloc
(
sizeof
(
content_t
));
...
@@ -118,7 +118,7 @@ int zmq::msg_t::init_data (void *data_, size_t size_, msg_free_fn *ffn_,
...
@@ -118,7 +118,7 @@ int zmq::msg_t::init_data (void *data_, size_t size_, msg_free_fn *ffn_,
int
zmq
::
msg_t
::
init_delimiter
()
int
zmq
::
msg_t
::
init_delimiter
()
{
{
u
.
delimiter
.
properties
=
NULL
;
u
.
delimiter
.
metadata
=
NULL
;
u
.
delimiter
.
type
=
type_delimiter
;
u
.
delimiter
.
type
=
type_delimiter
;
u
.
delimiter
.
flags
=
0
;
u
.
delimiter
.
flags
=
0
;
return
0
;
return
0
;
...
@@ -150,9 +150,9 @@ int zmq::msg_t::close ()
...
@@ -150,9 +150,9 @@ int zmq::msg_t::close ()
}
}
}
}
if
(
u
.
base
.
properties
!=
NULL
)
if
(
u
.
base
.
metadata
!=
NULL
)
if
(
u
.
base
.
properties
->
drop_ref
())
if
(
u
.
base
.
metadata
->
drop_ref
())
delete
u
.
base
.
properties
;
delete
u
.
base
.
metadata
;
// Make the message invalid.
// Make the message invalid.
u
.
base
.
type
=
0
;
u
.
base
.
type
=
0
;
...
@@ -205,8 +205,8 @@ int zmq::msg_t::copy (msg_t &src_)
...
@@ -205,8 +205,8 @@ int zmq::msg_t::copy (msg_t &src_)
}
}
}
}
if
(
src_
.
u
.
base
.
properties
!=
NULL
)
if
(
src_
.
u
.
base
.
metadata
!=
NULL
)
src_
.
u
.
base
.
properties
->
add_ref
();
src_
.
u
.
base
.
metadata
->
add_ref
();
*
this
=
src_
;
*
this
=
src_
;
...
@@ -275,17 +275,17 @@ void zmq::msg_t::set_fd (int64_t fd_)
...
@@ -275,17 +275,17 @@ void zmq::msg_t::set_fd (int64_t fd_)
file_desc
=
fd_
;
file_desc
=
fd_
;
}
}
zmq
::
i_properties
*
zmq
::
msg_t
::
properties
()
const
zmq
::
metadata_t
*
zmq
::
msg_t
::
metadata
()
const
{
{
return
u
.
base
.
properties
;
return
u
.
base
.
metadata
;
}
}
void
zmq
::
msg_t
::
set_
properties
(
zmq
::
i_properties
*
properties
_
)
void
zmq
::
msg_t
::
set_
metadata
(
zmq
::
metadata_t
*
metadata
_
)
{
{
assert
(
properties
_
!=
NULL
);
assert
(
metadata
_
!=
NULL
);
assert
(
u
.
base
.
properties
==
NULL
);
assert
(
u
.
base
.
metadata
==
NULL
);
properties
_
->
add_ref
();
metadata
_
->
add_ref
();
u
.
base
.
properties
=
properties
_
;
u
.
base
.
metadata
=
metadata
_
;
}
}
bool
zmq
::
msg_t
::
is_identity
()
const
bool
zmq
::
msg_t
::
is_identity
()
const
...
@@ -317,8 +317,8 @@ void zmq::msg_t::add_refs (int refs_)
...
@@ -317,8 +317,8 @@ void zmq::msg_t::add_refs (int refs_)
{
{
zmq_assert
(
refs_
>=
0
);
zmq_assert
(
refs_
>=
0
);
// Operation not supported for messages with
properties
.
// Operation not supported for messages with
metadata
.
zmq_assert
(
u
.
base
.
properties
==
NULL
);
zmq_assert
(
u
.
base
.
metadata
==
NULL
);
// No copies required.
// No copies required.
if
(
!
refs_
)
if
(
!
refs_
)
...
@@ -340,8 +340,8 @@ bool zmq::msg_t::rm_refs (int refs_)
...
@@ -340,8 +340,8 @@ bool zmq::msg_t::rm_refs (int refs_)
{
{
zmq_assert
(
refs_
>=
0
);
zmq_assert
(
refs_
>=
0
);
// Operation not supported for messages with
properties
.
// Operation not supported for messages with
metadata
.
zmq_assert
(
u
.
base
.
properties
==
NULL
);
zmq_assert
(
u
.
base
.
metadata
==
NULL
);
// No copies required.
// No copies required.
if
(
!
refs_
)
if
(
!
refs_
)
...
...
src/msg.hpp
View file @
87a08e17
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#include "config.hpp"
#include "config.hpp"
#include "atomic_counter.hpp"
#include "atomic_counter.hpp"
#include "
i_properties
.hpp"
#include "
metadata
.hpp"
// Signature for free function to deallocate the message content.
// Signature for free function to deallocate the message content.
// Note that it has to be declared as "C" so that it is the same as
// Note that it has to be declared as "C" so that it is the same as
...
@@ -71,8 +71,8 @@ namespace zmq
...
@@ -71,8 +71,8 @@ namespace zmq
void
reset_flags
(
unsigned
char
flags_
);
void
reset_flags
(
unsigned
char
flags_
);
int64_t
fd
();
int64_t
fd
();
void
set_fd
(
int64_t
fd_
);
void
set_fd
(
int64_t
fd_
);
i_properties
*
properties
()
const
;
metadata_t
*
metadata
()
const
;
void
set_
properties
(
i_properties
*
properties
_
);
void
set_
metadata
(
metadata_t
*
metadata
_
);
bool
is_identity
()
const
;
bool
is_identity
()
const
;
bool
is_credential
()
const
;
bool
is_credential
()
const
;
bool
is_delimiter
()
const
;
bool
is_delimiter
()
const
;
...
@@ -92,7 +92,7 @@ namespace zmq
...
@@ -92,7 +92,7 @@ namespace zmq
// Size in bytes of the largest message that is still copied around
// Size in bytes of the largest message that is still copied around
// rather than being reference-counted.
// rather than being reference-counted.
enum
{
msg_t_size
=
48
};
enum
{
msg_t_size
=
48
};
enum
{
max_vsm_size
=
msg_t_size
-
(
8
+
sizeof
(
i_properties
*
)
+
3
)
};
enum
{
max_vsm_size
=
msg_t_size
-
(
8
+
sizeof
(
metadata_t
*
)
+
3
)
};
// Shared message buffer. Message data are either allocated in one
// Shared message buffer. Message data are either allocated in one
// continuous block along with this structure - thus avoiding one
// continuous block along with this structure - thus avoiding one
...
@@ -134,37 +134,37 @@ namespace zmq
...
@@ -134,37 +134,37 @@ namespace zmq
// the union.
// the union.
union
{
union
{
struct
{
struct
{
i_properties
*
properties
;
metadata_t
*
metadata
;
unsigned
char
unused
[
msg_t_size
-
(
8
+
sizeof
(
i_properties
*
)
+
2
)];
unsigned
char
unused
[
msg_t_size
-
(
8
+
sizeof
(
metadata_t
*
)
+
2
)];
unsigned
char
type
;
unsigned
char
type
;
unsigned
char
flags
;
unsigned
char
flags
;
}
base
;
}
base
;
struct
{
struct
{
i_properties
*
properties
;
metadata_t
*
metadata
;
unsigned
char
data
[
max_vsm_size
];
unsigned
char
data
[
max_vsm_size
];
unsigned
char
size
;
unsigned
char
size
;
unsigned
char
type
;
unsigned
char
type
;
unsigned
char
flags
;
unsigned
char
flags
;
}
vsm
;
}
vsm
;
struct
{
struct
{
i_properties
*
properties
;
metadata_t
*
metadata
;
content_t
*
content
;
content_t
*
content
;
unsigned
char
unused
[
msg_t_size
-
(
8
+
sizeof
(
i_properties
*
)
+
sizeof
(
content_t
*
)
+
2
)];
unsigned
char
unused
[
msg_t_size
-
(
8
+
sizeof
(
metadata_t
*
)
+
sizeof
(
content_t
*
)
+
2
)];
unsigned
char
type
;
unsigned
char
type
;
unsigned
char
flags
;
unsigned
char
flags
;
}
lmsg
;
}
lmsg
;
struct
{
struct
{
i_properties
*
properties
;
metadata_t
*
metadata
;
void
*
data
;
void
*
data
;
size_t
size
;
size_t
size
;
unsigned
char
unused
unsigned
char
unused
[
msg_t_size
-
(
8
+
sizeof
(
i_properties
*
)
+
sizeof
(
void
*
)
+
sizeof
(
size_t
)
+
2
)];
[
msg_t_size
-
(
8
+
sizeof
(
metadata_t
*
)
+
sizeof
(
void
*
)
+
sizeof
(
size_t
)
+
2
)];
unsigned
char
type
;
unsigned
char
type
;
unsigned
char
flags
;
unsigned
char
flags
;
}
cmsg
;
}
cmsg
;
struct
{
struct
{
i_properties
*
properties
;
metadata_t
*
metadata
;
unsigned
char
unused
[
msg_t_size
-
(
8
+
sizeof
(
i_properties
*
)
+
2
)];
unsigned
char
unused
[
msg_t_size
-
(
8
+
sizeof
(
metadata_t
*
)
+
2
)];
unsigned
char
type
;
unsigned
char
type
;
unsigned
char
flags
;
unsigned
char
flags
;
}
delimiter
;
}
delimiter
;
...
...
src/stream_engine.cpp
View file @
87a08e17
...
@@ -814,7 +814,7 @@ int zmq::stream_engine_t::decode_and_push (msg_t *msg_)
...
@@ -814,7 +814,7 @@ int zmq::stream_engine_t::decode_and_push (msg_t *msg_)
if
(
mechanism
->
decode
(
msg_
)
==
-
1
)
if
(
mechanism
->
decode
(
msg_
)
==
-
1
)
return
-
1
;
return
-
1
;
if
(
metadata
)
if
(
metadata
)
msg_
->
set_
properties
(
metadata
);
msg_
->
set_
metadata
(
metadata
);
if
(
session
->
push_msg
(
msg_
)
==
-
1
)
{
if
(
session
->
push_msg
(
msg_
)
==
-
1
)
{
if
(
errno
==
EAGAIN
)
if
(
errno
==
EAGAIN
)
write_msg
=
&
stream_engine_t
::
push_one_then_decode_and_push
;
write_msg
=
&
stream_engine_t
::
push_one_then_decode_and_push
;
...
...
src/zmq.cpp
View file @
87a08e17
...
@@ -63,7 +63,7 @@ struct iovec {
...
@@ -63,7 +63,7 @@ struct iovec {
#include "err.hpp"
#include "err.hpp"
#include "msg.hpp"
#include "msg.hpp"
#include "fd.hpp"
#include "fd.hpp"
#include "
i_properties
.hpp"
#include "
metadata
.hpp"
#if !defined ZMQ_HAVE_WINDOWS
#if !defined ZMQ_HAVE_WINDOWS
#include <unistd.h>
#include <unistd.h>
...
@@ -647,9 +647,9 @@ int zmq_msg_set (zmq_msg_t *, int, int)
...
@@ -647,9 +647,9 @@ int zmq_msg_set (zmq_msg_t *, int, int)
const
char
*
zmq_msg_gets
(
zmq_msg_t
*
msg_
,
const
char
*
property_
)
const
char
*
zmq_msg_gets
(
zmq_msg_t
*
msg_
,
const
char
*
property_
)
{
{
zmq
::
i_properties
*
properties
=
((
zmq
::
msg_t
*
)
msg_
)
->
properties
();
zmq
::
metadata_t
*
metadata
=
((
zmq
::
msg_t
*
)
msg_
)
->
metadata
();
if
(
properties
)
if
(
metadata
)
return
properties
->
get
(
std
::
string
(
property_
));
return
metadata
->
get
(
std
::
string
(
property_
));
else
else
return
NULL
;
return
NULL
;
}
}
...
...
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