Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jlib
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
jlib
Commits
47972811
Commit
47972811
authored
Feb 02, 2021
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QDebug
parent
b79c26c6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
13 deletions
+23
-13
simple_libevent_server.cpp
jlib/net/simple_libevent_server.cpp
+7
-3
QtDebug.h
jlib/qt/QtDebug.h
+7
-2
lasterror.h
jlib/win32/lasterror.h
+2
-2
process.h
jlib/win32/process.h
+5
-5
simple_libevent_client_md.vcxproj
...mple_libevent_client_md/simple_libevent_client_md.vcxproj
+2
-1
No files found.
jlib/net/simple_libevent_server.cpp
View file @
47972811
...
...
@@ -374,9 +374,9 @@ bool simple_libevent_server::start(uint16_t port, std::string& msg)
}
impl
->
thread
=
std
::
thread
([
this
]()
{
JLOG_INFO
(
"{} listen thread started"
,
name_
.
data
()
);
JLOG_INFO
(
"{} listen thread started"
,
name_
);
event_base_dispatch
(
this
->
impl
->
base
);
JLOG_INFO
(
"{} listen thread exited"
,
name_
.
data
()
);
JLOG_INFO
(
"{} listen thread exited"
,
name_
);
});
started_
=
true
;
...
...
@@ -393,7 +393,7 @@ void simple_libevent_server::stop()
std
::
lock_guard
<
std
::
mutex
>
lg
(
mutex
);
if
(
!
impl
)
{
return
;
}
timeval
tv
{
0
,
1000
};
const
timeval
tv
{
0
,
1000
};
if
(
impl
->
base
)
{
event_base_loopexit
(
impl
->
base
,
&
tv
);
...
...
@@ -410,13 +410,17 @@ void simple_libevent_server::stop()
if
(
impl
->
workerThreadContexts
)
{
for
(
int
i
=
0
;
i
<
threadNum_
;
i
++
)
{
JLOG_DBUG
(
"simple_libevent_server::stop exiting worker #{}"
,
i
);
event_base_loopexit
(
impl
->
workerThreadContexts
[
i
]
->
base
,
&
tv
);
JLOG_DBUG
(
"simple_libevent_server::stop exited worker #{}"
,
i
);
}
for
(
int
i
=
0
;
i
<
threadNum_
;
i
++
)
{
JLOG_DBUG
(
"simple_libevent_server::stop joining worker #{}"
,
i
);
impl
->
workerThreadContexts
[
i
]
->
thread
.
join
();
event_base_free
(
impl
->
workerThreadContexts
[
i
]
->
base
);
delete
impl
->
workerThreadContexts
[
i
];
JLOG_DBUG
(
"simple_libevent_server::stop joined worker #{}"
,
i
);
}
delete
impl
->
workerThreadContexts
;
...
...
jlib/qt/QtDebug.h
View file @
47972811
...
...
@@ -6,14 +6,19 @@
#endif //_WIN32
#define JLIBQT_QDEBUG_FILE_LINE_STREAM "[" << __FUNCTION__
<< "ln"
<< __LINE__ << "]: "
#define JLIBQT_QDEBUG_FILE_LINE_VALUE (QString("[") + __FUNCTION__ + "
ln
" + QString::number(__LINE__) + "]: ")
#define JLIBQT_QDEBUG_FILE_LINE_STREAM "[" << __FUNCTION__ << __LINE__ << "]: "
#define JLIBQT_QDEBUG_FILE_LINE_VALUE (QString("[") + __FUNCTION__ + " " + QString::number(__LINE__) + "]: ")
#define MYQDEBUG qDebug() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQINFO qInfo() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQWARN qWarning() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQCRITICAL qCritical() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQDEBUG_NOQUOTE qDebug().noquote() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQINFO_NOQUOTE qInfo().noquote() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQWARN_NOQUOTE qWarning().noquote() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQCRITICAL_NOQUOTE qCritical().noquote() << JLIBQT_QDEBUG_FILE_LINE_STREAM
//! 弹窗报告行号开关
// #define JLIBQT_SHOW_LINE 0
//! 当行号大于下方定义的值时,弹窗报告行号,否则忽略。可在多个cpp文件分别定义不同的值。
...
...
jlib/win32/lasterror.h
View file @
47972811
...
...
@@ -6,7 +6,7 @@
namespace
jlib
{
namespace
win32
{
std
::
string
formatLastError
(
const
std
::
string
&
msg
)
inline
std
::
string
formatLastError
(
const
std
::
string
&
msg
)
{
// Get system msg
char
sysMsg
[
256
];
...
...
@@ -24,7 +24,7 @@ std::string formatLastError(const std::string& msg)
return
msg
+
" failed with error "
+
std
::
to_string
(
eNum
)
+
" ("
+
sysMsg
+
")"
;
}
std
::
wstring
formatLastError
(
const
std
::
wstring
&
msg
)
inline
std
::
wstring
formatLastError
(
const
std
::
wstring
&
msg
)
{
// Get system msg
wchar_t
sysMsg
[
256
];
...
...
jlib/win32/process.h
View file @
47972811
...
...
@@ -167,16 +167,16 @@ inline JsonValue toJson(const ProcessInfos& pinfos) {
typedef
std
::
function
<
void
(
const
std
::
wstring
&
)
>
ErrorOutputFunc
;
static
void
dummyErrorOutputFunc
(
const
std
::
wstring
&
msg
)
{
inline
void
dummyErrorOutputFunc
(
const
std
::
wstring
&
msg
)
{
printf
(
"%ls
\n
"
,
msg
.
data
());
}
static
void
outputLastErrorHelper
(
const
std
::
wstring
&
msg
,
ErrorOutputFunc
func
=
nullptr
)
{
inline
void
outputLastErrorHelper
(
const
std
::
wstring
&
msg
,
ErrorOutputFunc
func
=
nullptr
)
{
if
(
!
func
)
{
return
;
}
func
(
formatLastError
(
msg
));
}
static
std
::
vector
<
ProcessInfo
::
ModuleInfo
>
getProcessModules
(
DWORD
dwPID
,
ErrorOutputFunc
output
=
dummyErrorOutputFunc
)
inline
std
::
vector
<
ProcessInfo
::
ModuleInfo
>
getProcessModules
(
DWORD
dwPID
,
ErrorOutputFunc
output
=
dummyErrorOutputFunc
)
{
std
::
vector
<
ProcessInfo
::
ModuleInfo
>
modules
=
{};
...
...
@@ -217,7 +217,7 @@ static std::vector<ProcessInfo::ModuleInfo> getProcessModules(DWORD dwPID, Error
return
(
modules
);
}
static
std
::
vector
<
ProcessInfo
::
ThreadInfo
>
getProcessThreads
(
DWORD
dwOwnerPID
,
ErrorOutputFunc
output
=
dummyErrorOutputFunc
)
inline
std
::
vector
<
ProcessInfo
::
ThreadInfo
>
getProcessThreads
(
DWORD
dwOwnerPID
,
ErrorOutputFunc
output
=
dummyErrorOutputFunc
)
{
std
::
vector
<
ProcessInfo
::
ThreadInfo
>
threads
=
{};
...
...
@@ -326,7 +326,7 @@ static const wchar_t* PROCESS_FILTER[] = {
L"YourPhone.exe"
,
};
static
ProcessInfos
getProcessesInfo
(
ErrorOutputFunc
output
=
dummyErrorOutputFunc
,
bool
withModules
=
false
,
bool
withThreads
=
false
,
const
wchar_t
**
filter
=
PROCESS_FILTER
,
size_t
filter_count
=
_countof
(
PROCESS_FILTER
))
inline
ProcessInfos
getProcessesInfo
(
ErrorOutputFunc
output
=
dummyErrorOutputFunc
,
bool
withModules
=
false
,
bool
withThreads
=
false
,
const
wchar_t
**
filter
=
PROCESS_FILTER
,
size_t
filter_count
=
_countof
(
PROCESS_FILTER
))
{
// pre-process filter
std
::
unordered_set
<
std
::
wstring
>
filterset
;
...
...
test/simple_libevent_client_md/simple_libevent_client_md.vcxproj
View file @
47972811
...
...
@@ -155,8 +155,9 @@
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
NDEBUG;_LIB;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeader>
Use
</PrecompiledHeader>
<PrecompiledHeader>
NotUsing
</PrecompiledHeader>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>
$(DEVLIBS)\libevent-2.1.12-stable-install\include;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
...
...
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