Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
pistache
Commits
3beb79cc
Unverified
Commit
3beb79cc
authored
Nov 17, 2018
by
Dennis Jenkins
Committed by
GitHub
Nov 17, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #354 from knowledge4igor/code_improvements_8
Code improvements and fix warnings
parents
5f629561
65f27d31
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
21 deletions
+25
-21
include/pistache/client.h
include/pistache/client.h
+7
-7
include/pistache/transport.h
include/pistache/transport.h
+7
-3
src/client/client.cc
src/client/client.cc
+6
-6
src/common/transport.cc
src/common/transport.cc
+5
-5
No files found.
include/pistache/client.h
View file @
3beb79cc
...
...
@@ -157,9 +157,9 @@ public:
void
closeIdleConnections
(
const
std
::
string
&
domain
);
private:
typedef
std
::
vector
<
std
::
shared_ptr
<
Connection
>>
Connections
;
typedef
std
::
mutex
Lock
;
typedef
std
::
lock_guard
<
Lock
>
Guard
;
using
Connections
=
std
::
vector
<
std
::
shared_ptr
<
Connection
>>
;
using
Lock
=
std
::
mutex
;
using
Guard
=
std
::
lock_guard
<
Lock
>
;
mutable
Lock
connsLock
;
std
::
unordered_map
<
std
::
string
,
Connections
>
conns
;
...
...
@@ -296,7 +296,7 @@ public:
RequestBuilder
&
body
(
const
std
::
string
&
val
);
RequestBuilder
&
body
(
std
::
string
&&
val
);
RequestBuilder
&
timeout
(
std
::
chrono
::
milliseconds
val
ue
);
RequestBuilder
&
timeout
(
std
::
chrono
::
milliseconds
val
);
Async
::
Promise
<
Response
>
send
();
...
...
@@ -361,8 +361,8 @@ private:
std
::
atomic
<
uint64_t
>
ioIndex
;
typedef
std
::
mutex
Lock
;
typedef
std
::
lock_guard
<
Lock
>
Guard
;
using
Lock
=
std
::
mutex
;
using
Guard
=
std
::
lock_guard
<
Lock
>
;
Lock
queuesLock
;
std
::
unordered_map
<
std
::
string
,
MPMCQueue
<
std
::
shared_ptr
<
Connection
::
RequestData
>
,
2048
>>
requestsQueues
;
...
...
@@ -370,7 +370,7 @@ private:
RequestBuilder
prepareRequest
(
const
std
::
string
&
resource
,
Http
::
Method
method
);
Async
::
Promise
<
Response
>
doRequest
(
Http
::
Request
req
,
Http
::
Request
req
uest
,
std
::
chrono
::
milliseconds
timeout
);
void
processRequestQueue
();
...
...
include/pistache/transport.h
View file @
3beb79cc
...
...
@@ -26,7 +26,9 @@ class Handler;
class
Transport
:
public
Aio
::
Handler
{
public:
Transport
(
const
std
::
shared_ptr
<
Tcp
::
Handler
>&
handler
);
explicit
Transport
(
const
std
::
shared_ptr
<
Tcp
::
Handler
>&
handler
);
Transport
(
const
Transport
&
)
=
delete
;
Transport
&
operator
=
(
const
Transport
&
)
=
delete
;
void
init
(
const
std
::
shared_ptr
<
Tcp
::
Handler
>&
handler
);
...
...
@@ -197,10 +199,12 @@ private:
std
::
shared_ptr
<
Peer
>
peer
;
};
using
Lock
=
std
::
mutex
;
using
Guard
=
std
::
lock_guard
<
Lock
>
;
PollableQueue
<
WriteEntry
>
writesQueue
;
std
::
unordered_map
<
Fd
,
std
::
deque
<
WriteEntry
>
>
toWrite
;
std
::
mutex
toWriteLock
;
std
::
unordered_map
<
Fd
,
std
::
deque
<
WriteEntry
>>
toWrite
;
Lock
toWriteLock
;
PollableQueue
<
TimerEntry
>
timersQueue
;
std
::
unordered_map
<
Fd
,
TimerEntry
>
timers
;
...
...
src/client/client.cc
View file @
3beb79cc
...
...
@@ -436,9 +436,9 @@ Connection::hasTransport() const {
}
void
Connection
::
handleResponsePacket
(
const
char
*
buffer
,
size_t
b
ytes
)
{
Connection
::
handleResponsePacket
(
const
char
*
buffer
,
size_t
totalB
ytes
)
{
parser_
.
feed
(
buffer
,
b
ytes
);
parser_
.
feed
(
buffer
,
totalB
ytes
);
if
(
parser_
.
parse
()
==
Private
::
State
::
Done
)
{
if
(
!
inflightRequests
.
empty
())
{
auto
req
=
std
::
move
(
inflightRequests
.
front
());
...
...
@@ -695,8 +695,8 @@ RequestBuilder::resource(const std::string& val) {
}
RequestBuilder
&
RequestBuilder
::
params
(
const
Uri
::
Query
&
params
)
{
request_
.
query_
=
params
;
RequestBuilder
::
params
(
const
Uri
::
Query
&
query
)
{
request_
.
query_
=
query
;
return
*
this
;
}
...
...
@@ -725,8 +725,8 @@ RequestBuilder::body(std::string&& val) {
}
RequestBuilder
&
RequestBuilder
::
timeout
(
std
::
chrono
::
milliseconds
timeout
)
{
timeout_
=
timeout
;
RequestBuilder
::
timeout
(
std
::
chrono
::
milliseconds
val
)
{
timeout_
=
val
;
return
*
this
;
}
...
...
src/common/transport.cc
View file @
3beb79cc
...
...
@@ -56,7 +56,7 @@ Transport::handleNewPeer(const std::shared_ptr<Tcp::Peer>& peer) {
}
int
fd
=
peer
->
fd
();
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
toWriteLock
);
Guard
guard
(
toWriteLock
);
toWrite
.
emplace
(
fd
,
std
::
deque
<
WriteEntry
>
{});
}
}
...
...
@@ -98,7 +98,7 @@ Transport::onReady(const Aio::FdSet& fds) {
auto
fd
=
tag
.
value
();
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
toWriteLock
);
Guard
guard
(
toWriteLock
);
auto
it
=
toWrite
.
find
(
fd
);
if
(
it
==
std
::
end
(
toWrite
))
{
throw
std
::
runtime_error
(
"Assertion Error: could not find write data"
);
...
...
@@ -171,7 +171,7 @@ Transport::handlePeerDisconnection(const std::shared_ptr<Peer>& peer) {
{
// Clean up buffers
std
::
lock_guard
<
std
::
mutex
>
lock
(
toWriteLock
);
Guard
guard
(
toWriteLock
);
auto
&
wq
=
toWrite
[
fd
];
while
(
wq
.
size
()
>
0
)
{
auto
&
entry
=
wq
.
front
();
...
...
@@ -193,7 +193,7 @@ Transport::asyncWriteImpl(Fd fd)
{
bool
stop
=
false
;
while
(
!
stop
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
toWriteLock
);
Guard
guard
(
toWriteLock
);
auto
it
=
toWrite
.
find
(
fd
);
...
...
@@ -330,7 +330,7 @@ Transport::handleWriteQueue() {
if
(
!
isPeerFd
(
fd
))
continue
;
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
toWriteLock
);
Guard
guard
(
toWriteLock
);
toWrite
[
fd
].
push_back
(
std
::
move
(
write
));
}
...
...
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