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
1960b4e8
Commit
1960b4e8
authored
Jan 28, 2016
by
somdoron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filtering messages on dish side
parent
c7d52ec2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
dish.cpp
src/dish.cpp
+14
-3
dish.hpp
src/dish.hpp
+1
-1
No files found.
src/dish.cpp
View file @
1960b4e8
...
@@ -97,8 +97,7 @@ int zmq::dish_t::xjoin (const char* group_)
...
@@ -97,8 +97,7 @@ int zmq::dish_t::xjoin (const char* group_)
return
-
1
;
return
-
1
;
}
}
subscriptions_t
::
iterator
it
=
subscriptions_t
::
iterator
it
=
subscriptions
.
find
(
group
);
std
::
find
(
subscriptions
.
begin
(),
subscriptions
.
end
(),
group
);
// User cannot join same group twice
// User cannot join same group twice
if
(
it
!=
subscriptions
.
end
())
{
if
(
it
!=
subscriptions
.
end
())
{
...
@@ -106,7 +105,7 @@ int zmq::dish_t::xjoin (const char* group_)
...
@@ -106,7 +105,7 @@ int zmq::dish_t::xjoin (const char* group_)
return
-
1
;
return
-
1
;
}
}
subscriptions
.
push_back
(
group
);
subscriptions
.
insert
(
group
);
msg_t
msg
;
msg_t
msg
;
int
rc
=
msg
.
init_join
();
int
rc
=
msg
.
init_join
();
...
@@ -185,6 +184,8 @@ int zmq::dish_t::xrecv (msg_t *msg_)
...
@@ -185,6 +184,8 @@ int zmq::dish_t::xrecv (msg_t *msg_)
return
0
;
return
0
;
}
}
while
(
true
)
{
// Get a message using fair queueing algorithm.
// Get a message using fair queueing algorithm.
int
rc
=
fq
.
recv
(
msg_
);
int
rc
=
fq
.
recv
(
msg_
);
...
@@ -193,7 +194,11 @@ int zmq::dish_t::xrecv (msg_t *msg_)
...
@@ -193,7 +194,11 @@ int zmq::dish_t::xrecv (msg_t *msg_)
if
(
rc
!=
0
)
if
(
rc
!=
0
)
return
-
1
;
return
-
1
;
// Filtering non matching messages
subscriptions_t
::
iterator
it
=
subscriptions
.
find
(
std
::
string
(
msg_
->
group
()));
if
(
it
!=
subscriptions
.
end
())
return
0
;
return
0
;
}
}
}
bool
zmq
::
dish_t
::
xhas_in
()
bool
zmq
::
dish_t
::
xhas_in
()
...
@@ -203,6 +208,7 @@ bool zmq::dish_t::xhas_in ()
...
@@ -203,6 +208,7 @@ bool zmq::dish_t::xhas_in ()
if
(
has_message
)
if
(
has_message
)
return
true
;
return
true
;
while
(
true
)
{
// Get a message using fair queueing algorithm.
// Get a message using fair queueing algorithm.
int
rc
=
fq
.
recv
(
&
message
);
int
rc
=
fq
.
recv
(
&
message
);
...
@@ -213,8 +219,13 @@ bool zmq::dish_t::xhas_in ()
...
@@ -213,8 +219,13 @@ bool zmq::dish_t::xhas_in ()
return
false
;
return
false
;
}
}
// Filtering non matching messages
subscriptions_t
::
iterator
it
=
subscriptions
.
find
(
std
::
string
(
message
.
group
()));
if
(
it
!=
subscriptions
.
end
())
{
has_message
=
true
;
has_message
=
true
;
return
true
;
return
true
;
}
}
}
}
zmq
::
blob_t
zmq
::
dish_t
::
get_credential
()
const
zmq
::
blob_t
zmq
::
dish_t
::
get_credential
()
const
...
...
src/dish.hpp
View file @
1960b4e8
...
@@ -81,7 +81,7 @@ namespace zmq
...
@@ -81,7 +81,7 @@ namespace zmq
dist_t
dist
;
dist_t
dist
;
// The repository of subscriptions.
// The repository of subscriptions.
typedef
std
::
vector
<
std
::
string
>
subscriptions_t
;
typedef
std
::
set
<
std
::
string
>
subscriptions_t
;
subscriptions_t
subscriptions
;
subscriptions_t
subscriptions
;
// If true, 'message' contains a matching message to return on the
// If true, 'message' contains a matching message to return on the
...
...
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