Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
CymGen30
libcloudstorage
Commits
f7b5d81c
Commit
f7b5d81c
authored
Feb 27, 2018
by
Paweł Wegner
Browse files
cloudbrowser: use other thread pool for context operations.
parent
ec97b696
Changes
2
Hide whitespace changes
Inline
Side-by-side
bin/cloudbrowser/src/CloudContext.cpp
View file @
f7b5d81c
...
...
@@ -98,6 +98,7 @@ CloudContext::CloudContext(QObject* parent)
IHttpServerFactory
::
create
())),
http_
(
IHttp
::
create
()),
thread_pool_
(
IThreadPool
::
create
(
1
)),
context_thread_pool_
(
IThreadPool
::
create
(
1
)),
cache_size_
(
updatedCacheSize
())
{
util
::
log_stream
(
util
::
make_unique
<
std
::
ostream
>
(
&
debug_stream_
));
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
...
...
@@ -129,8 +130,6 @@ CloudContext::CloudContext(QObject* parent)
}
CloudContext
::~
CloudContext
()
{
save
();
thread_pool_
=
nullptr
;
util
::
log_stream
(
util
::
make_unique
<
std
::
ostream
>
(
std
::
cerr
.
rdbuf
()));
}
...
...
@@ -178,12 +177,11 @@ void CloudContext::saveCachedDirectories() {
file
.
write
(
QJsonDocument
(
json
).
toBinaryData
());
}
void
CloudContext
::
save
()
{
thread_pool_
->
schedule
([
this
]
{
void
CloudContext
::
save
Providers
()
{
schedule
([
this
]
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
QSettings
settings
;
settings
.
setValue
(
"providers"
,
user_provider_model_
.
dump
());
saveCachedDirectories
();
});
}
...
...
@@ -234,7 +232,7 @@ void CloudContext::removeProvider(QVariant provider) {
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
user_provider_model_
.
remove
(
provider
);
}
save
();
save
Providers
();
}
QString
CloudContext
::
pretty
(
QString
provider
)
const
{
...
...
@@ -352,7 +350,7 @@ IItem::List CloudContext::cachedDirectory(ListDirectoryCacheKey key) {
}
void
CloudContext
::
schedule
(
std
::
function
<
void
()
>
f
)
{
thread_pool_
->
schedule
(
f
);
context_
thread_pool_
->
schedule
(
f
);
}
void
CloudContext
::
receivedCode
(
std
::
string
provider
,
std
::
string
code
)
{
...
...
@@ -377,7 +375,7 @@ void CloudContext::receivedCode(std::string provider, std::string code) {
{
d
.
right
()
->
username_
,
this
->
provider
(
provider
,
d
.
right
()
->
username_
,
*
e
.
right
())});
}
save
();
save
Providers
();
}));
});
pool_
.
add
(
std
::
move
(
p
),
std
::
move
(
r
));
...
...
bin/cloudbrowser/src/CloudContext.h
View file @
f7b5d81c
...
...
@@ -55,11 +55,6 @@ class CloudContext : public QObject {
CloudContext
(
QObject
*
parent
=
nullptr
);
~
CloudContext
();
void
loadCachedDirectories
();
void
saveCachedDirectories
();
void
save
();
QStringList
providers
()
const
;
ProviderListModel
*
userProviders
();
bool
includeAds
()
const
;
...
...
@@ -135,6 +130,9 @@ class CloudContext : public QObject {
QString
current_line_
;
};
void
loadCachedDirectories
();
void
saveCachedDirectories
();
void
saveProviders
();
void
receivedCode
(
std
::
string
provider
,
std
::
string
code
);
cloudstorage
::
ICloudProvider
::
Pointer
provider
(
const
std
::
string
&
name
,
const
std
::
string
&
label
,
...
...
@@ -149,6 +147,7 @@ class CloudContext : public QObject {
std
::
vector
<
std
::
shared_ptr
<
cloudstorage
::
IHttpServer
>>
auth_server_
;
std
::
shared_ptr
<
cloudstorage
::
IHttp
>
http_
;
std
::
shared_ptr
<
cloudstorage
::
IThreadPool
>
thread_pool_
;
cloudstorage
::
IThreadPool
::
Pointer
context_thread_pool_
;
RequestPool
pool_
;
std
::
unordered_map
<
ListDirectoryCacheKey
,
std
::
vector
<
cloudstorage
::
IItem
::
Pointer
>>
...
...
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