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
3666a490
Commit
3666a490
authored
Aug 29, 2009
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug in identifying current thread fixed
parent
6996ef6f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
6 deletions
+40
-6
app_thread.cpp
src/app_thread.cpp
+5
-3
app_thread.hpp
src/app_thread.hpp
+6
-3
thread.cpp
src/thread.cpp
+20
-0
thread.hpp
src/thread.hpp
+9
-0
No files found.
src/app_thread.cpp
View file @
3666a490
...
...
@@ -44,7 +44,7 @@
zmq
::
app_thread_t
::
app_thread_t
(
dispatcher_t
*
dispatcher_
,
int
thread_slot_
)
:
object_t
(
dispatcher_
,
thread_slot_
),
tid
(
0
),
associated
(
false
),
last_processing_time
(
0
)
{
}
...
...
@@ -63,7 +63,8 @@ zmq::i_signaler *zmq::app_thread_t::get_signaler ()
bool
zmq
::
app_thread_t
::
is_current
()
{
return
!
sockets
.
empty
()
&&
tid
==
getpid
();
return
!
sockets
.
empty
()
&&
associated
&&
thread_t
::
equal
(
tid
,
thread_t
::
id
());
}
bool
zmq
::
app_thread_t
::
make_current
()
...
...
@@ -73,7 +74,8 @@ bool zmq::app_thread_t::make_current ()
if
(
!
sockets
.
empty
())
return
false
;
tid
=
getpid
();
associated
=
true
;
tid
=
thread_t
::
id
();
return
true
;
}
...
...
src/app_thread.hpp
View file @
3666a490
...
...
@@ -25,6 +25,7 @@
#include "stdint.hpp"
#include "object.hpp"
#include "ypollset.hpp"
#include "thread.hpp"
namespace
zmq
{
...
...
@@ -69,10 +70,12 @@ namespace zmq
typedef
std
::
vector
<
class
socket_base_t
*>
sockets_t
;
sockets_t
sockets
;
// If false, app_thread_t object is not associated with any OS thread.
// In such case, 'tid' member contains a bogus value.
bool
associated
;
// Thread ID associated with this slot.
// TODO: Virtualise pid_t!
// TODO: Check whether getpid returns unique ID for each thread.
int
tid
;
thread_t
::
id_t
tid
;
// App thread's signaler object.
ypollset_t
pollset
;
...
...
src/thread.cpp
View file @
3666a490
...
...
@@ -38,6 +38,16 @@ void zmq::thread_t::stop ()
win_assert
(
rc
!=
WAIT_FAILED
);
}
zmq
::
thread_t
::
id_t
zmq
::
thread_t
::
id
()
{
return
GetCurrentThreadId
();
}
bool
zmq
::
thread_t
::
equal
(
id_t
id1_
,
id_t
id2_
)
{
return
id1_
==
id2_
;
}
unsigned
int
__stdcall
zmq
::
thread_t
::
thread_routine
(
void
*
arg_
)
{
thread_t
*
self
=
(
thread_t
*
)
arg_
;
...
...
@@ -63,6 +73,16 @@ void zmq::thread_t::stop ()
errno_assert
(
rc
==
0
);
}
zmq
::
thread_t
::
id_t
zmq
::
thread_t
::
id
()
{
return
pthread_self
();
}
bool
zmq
::
thread_t
::
equal
(
id_t
id1_
,
id_t
id2_
)
{
return
pthread_equal
(
id1_
,
id2_
)
!=
0
;
}
void
*
zmq
::
thread_t
::
thread_routine
(
void
*
arg_
)
{
#if !defined ZMQ_HAVE_OPENVMS
...
...
src/thread.hpp
View file @
3666a490
...
...
@@ -55,6 +55,15 @@ namespace zmq
// Waits for thread termination.
void
stop
();
#ifdef ZMQ_HAVE_WINDOWS
typedef
DWORD
id_t
;
#else
typedef
pthread_t
id_t
;
#endif
static
id_t
id
();
static
bool
equal
(
id_t
id1_
,
id_t
id2_
);
private
:
#ifdef ZMQ_HAVE_WINDOWS
...
...
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