Skip to content

Commit

Permalink
Submit cache on application start
Browse files Browse the repository at this point in the history
  • Loading branch information
phw committed Oct 25, 2023
1 parent 238ef8c commit 16c2125
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/foo_listenbrainz2.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include "stdafx.h"
#include "http_task.h"

namespace lbz
{
DECLARE_COMPONENT_VERSION(component_name, component_version, component_info);
VALIDATE_COMPONENT_FILENAME(component_dll_name);

FB2K_RUN_ON_INIT(submit_cache_async);
}
11 changes: 10 additions & 1 deletion src/http_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace lbz
}
}

void http_task::submit_cache()
void submit_cache()
{
listen_cache* cache = &prefs::cache;
if (cache->empty()) return;
Expand All @@ -117,4 +117,13 @@ namespace lbz
http_task task(listen_type::import, j);
task.run();
}

void submit_cache_async()
{
auto t = std::thread([=]()
{
submit_cache();
});
t.detach();
}
}
4 changes: 3 additions & 1 deletion src/http_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ namespace lbz
private:
void cache();
void process_response(json j);
void submit_cache();

json m_data;
listen_type m_listen_type;
};

void submit_cache();
void submit_cache_async();
}

0 comments on commit 16c2125

Please sign in to comment.