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
a83baa9b
Commit
a83baa9b
authored
Aug 17, 2013
by
Richard Newton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix up threading code from port tests to windows.
parent
7f74fc7c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
24 deletions
+18
-24
zmq_utils.h
include/zmq_utils.h
+3
-1
zmq_utils.cpp
src/zmq_utils.cpp
+2
-2
test_monitor.cpp
tests/test_monitor.cpp
+6
-9
test_security.cpp
tests/test_security.cpp
+1
-4
test_security_curve.cpp
tests/test_security_curve.cpp
+1
-4
test_shutdown_stress.cpp
tests/test_shutdown_stress.cpp
+2
-4
testutil.hpp
tests/testutil.hpp
+3
-0
No files found.
include/zmq_utils.h
View file @
a83baa9b
...
...
@@ -43,6 +43,8 @@ extern "C" {
# endif
#endif
typedef
void
(
zmq_thread_fn
)
(
void
*
);
/* Helper functions are used by perf tests so that they don't have to care */
/* about minutiae of time-related functions on different OS platforms. */
...
...
@@ -57,7 +59,7 @@ ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_);
ZMQ_EXPORT
void
zmq_sleep
(
int
seconds_
);
/* Start a thread. Returns a handle to the thread. */
ZMQ_EXPORT
void
*
zmq_threadstart
(
void
*
func
,
void
*
arg
);
ZMQ_EXPORT
void
*
zmq_threadstart
(
zmq_thread_fn
*
func
,
void
*
arg
);
/* Wait for thread to complete then free up resources. */
ZMQ_EXPORT
void
zmq_threadclose
(
void
*
thread
);
...
...
src/zmq_utils.cpp
View file @
a83baa9b
...
...
@@ -59,10 +59,10 @@ unsigned long zmq_stopwatch_stop (void *watch_)
return
(
unsigned
long
)
(
end
-
start
);
}
void
*
zmq_threadstart
(
void
*
func
,
void
*
arg
)
void
*
zmq_threadstart
(
zmq_thread_fn
*
func
,
void
*
arg
)
{
zmq
::
thread_t
*
thread
=
new
zmq
::
thread_t
;
thread
->
start
(
static_cast
<
zmq
::
thread_fn
*>
(
func
)
,
arg
);
thread
->
start
(
func
,
arg
);
return
thread
;
}
...
...
tests/test_monitor.cpp
View file @
a83baa9b
...
...
@@ -66,7 +66,7 @@ static bool read_msg(void* s, zmq_event_t& event, std::string& ep)
// REQ socket monitor thread
static
void
*
req_socket_monitor
(
void
*
ctx
)
static
void
req_socket_monitor
(
void
*
ctx
)
{
zmq_event_t
event
;
std
::
string
ep
;
...
...
@@ -104,11 +104,10 @@ static void *req_socket_monitor (void *ctx)
}
}
zmq_close
(
s
);
return
NULL
;
}
// 2nd REQ socket monitor thread
static
void
*
req2_socket_monitor
(
void
*
ctx
)
static
void
req2_socket_monitor
(
void
*
ctx
)
{
zmq_event_t
event
;
std
::
string
ep
;
...
...
@@ -133,11 +132,10 @@ static void *req2_socket_monitor (void *ctx)
}
}
zmq_close
(
s
);
return
NULL
;
}
// REP socket monitor thread
static
void
*
rep_socket_monitor
(
void
*
ctx
)
static
void
rep_socket_monitor
(
void
*
ctx
)
{
zmq_event_t
event
;
std
::
string
ep
;
...
...
@@ -174,7 +172,6 @@ static void *rep_socket_monitor (void *ctx)
}
}
zmq_close
(
s
);
return
NULL
;
}
int
main
(
void
)
...
...
@@ -208,7 +205,7 @@ int main (void)
// REP socket monitor, all events
rc
=
zmq_socket_monitor
(
rep
,
"inproc://monitor.rep"
,
ZMQ_EVENT_ALL
);
assert
(
rc
==
0
);
threads
[
0
]
=
zmq_threadstart
(
rep_socket_monitor
,
ctx
);
threads
[
0
]
=
zmq_threadstart
(
&
rep_socket_monitor
,
ctx
);
// REQ socket
req
=
zmq_socket
(
ctx
,
ZMQ_REQ
);
...
...
@@ -217,7 +214,7 @@ int main (void)
// REQ socket monitor, all events
rc
=
zmq_socket_monitor
(
req
,
"inproc://monitor.req"
,
ZMQ_EVENT_ALL
);
assert
(
rc
==
0
);
threads
[
1
]
=
zmq_threadstart
(
req_socket_monitor
,
ctx
);
threads
[
1
]
=
zmq_threadstart
(
&
req_socket_monitor
,
ctx
);
zmq_sleep
(
1
);
// Bind REQ and REP
...
...
@@ -236,7 +233,7 @@ int main (void)
// 2nd REQ socket monitor, connected event only
rc
=
zmq_socket_monitor
(
req2
,
"inproc://monitor.req2"
,
ZMQ_EVENT_CONNECTED
);
assert
(
rc
==
0
);
threads
[
2
]
=
zmq_threadstart
(
req2_socket_monitor
,
ctx
);
threads
[
2
]
=
zmq_threadstart
(
&
req2_socket_monitor
,
ctx
);
rc
=
zmq_connect
(
req2
,
addr
.
c_str
());
assert
(
rc
==
0
);
...
...
tests/test_security.cpp
View file @
a83baa9b
...
...
@@ -22,8 +22,7 @@
#include <stdlib.h>
#include "testutil.hpp"
static
void
*
zap_handler
(
void
*
zap
)
static
void
zap_handler
(
void
*
zap
)
{
char
*
version
=
s_recv
(
zap
);
char
*
sequence
=
s_recv
(
zap
);
...
...
@@ -62,8 +61,6 @@ zap_handler (void *zap)
int
rc
=
zmq_close
(
zap
);
assert
(
rc
==
0
);
return
NULL
;
}
int
main
(
void
)
...
...
tests/test_security_curve.cpp
View file @
a83baa9b
...
...
@@ -23,8 +23,7 @@
#include <stdlib.h>
#include "testutil.hpp"
static
void
*
zap_handler
(
void
*
zap
)
static
void
zap_handler
(
void
*
zap
)
{
char
*
version
=
s_recv
(
zap
);
char
*
sequence
=
s_recv
(
zap
);
...
...
@@ -52,8 +51,6 @@ zap_handler (void *zap)
int
rc
=
zmq_close
(
zap
);
assert
(
rc
==
0
);
return
NULL
;
}
int
main
(
void
)
...
...
tests/test_shutdown_stress.cpp
View file @
a83baa9b
...
...
@@ -27,7 +27,7 @@
extern
"C"
{
static
void
*
worker
(
void
*
s
)
static
void
worker
(
void
*
s
)
{
int
rc
;
...
...
@@ -37,8 +37,6 @@ extern "C"
// Start closing the socket while the connecting process is underway.
rc
=
zmq_close
(
s
);
assert
(
rc
==
0
);
return
NULL
;
}
}
...
...
@@ -68,7 +66,7 @@ int main (void)
for
(
i
=
0
;
i
!=
THREAD_COUNT
;
i
++
)
{
s2
=
zmq_socket
(
ctx
,
ZMQ_SUB
);
assert
(
s2
);
threads
[
i
]
=
zmq_threadstart
(
worker
,
s2
);
threads
[
i
]
=
zmq_threadstart
(
&
worker
,
s2
);
}
for
(
i
=
0
;
i
!=
THREAD_COUNT
;
i
++
)
{
...
...
tests/testutil.hpp
View file @
a83baa9b
...
...
@@ -28,6 +28,7 @@
#include <stdarg.h>
#if defined _WIN32
#include <crtdbg.h>
#pragma warning(disable:4996)
#endif
...
...
@@ -200,6 +201,8 @@ void setup_test_environment()
{
#if defined _WIN32
_set_abort_behavior
(
0
,
_WRITE_ABORT_MSG
);
_CrtSetReportMode
(
_CRT_ASSERT
,
_CRTDBG_MODE_FILE
);
_CrtSetReportFile
(
_CRT_ASSERT
,
_CRTDBG_FILE_STDERR
);
#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