mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 15:56:18 +02:00
Merge pull request #1965 from masaeedu/master
Wrap thread local in function for Cygwin
This commit is contained in:
commit
7b8914825a
3 changed files with 17 additions and 7 deletions
|
@ -22,7 +22,7 @@ struct DownloadRequest
|
|||
std::string mimeType;
|
||||
|
||||
DownloadRequest(const std::string & uri)
|
||||
: uri(uri), parentAct(curActivity) { }
|
||||
: uri(uri), parentAct(getCurActivity()) { }
|
||||
};
|
||||
|
||||
struct DownloadResult
|
||||
|
|
|
@ -6,7 +6,16 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
thread_local ActivityId curActivity = 0;
|
||||
static thread_local ActivityId curActivity = 0;
|
||||
|
||||
ActivityId getCurActivity()
|
||||
{
|
||||
return curActivity;
|
||||
}
|
||||
void setCurActivity(const ActivityId activityId)
|
||||
{
|
||||
curActivity = activityId;
|
||||
}
|
||||
|
||||
Logger * logger = makeDefaultLogger();
|
||||
|
||||
|
|
|
@ -77,7 +77,8 @@ public:
|
|||
virtual void result(ActivityId act, ResultType type, const Fields & fields) { };
|
||||
};
|
||||
|
||||
extern thread_local ActivityId curActivity;
|
||||
ActivityId getCurActivity();
|
||||
void setCurActivity(const ActivityId activityId);
|
||||
|
||||
struct Activity
|
||||
{
|
||||
|
@ -86,10 +87,10 @@ struct Activity
|
|||
const ActivityId id;
|
||||
|
||||
Activity(Logger & logger, Verbosity lvl, ActivityType type, const std::string & s = "",
|
||||
const Logger::Fields & fields = {}, ActivityId parent = curActivity);
|
||||
const Logger::Fields & fields = {}, ActivityId parent = getCurActivity());
|
||||
|
||||
Activity(Logger & logger, ActivityType type,
|
||||
const Logger::Fields & fields = {}, ActivityId parent = curActivity)
|
||||
const Logger::Fields & fields = {}, ActivityId parent = getCurActivity())
|
||||
: Activity(logger, lvlError, type, "", fields, parent) { };
|
||||
|
||||
Activity(const Activity & act) = delete;
|
||||
|
@ -121,8 +122,8 @@ struct Activity
|
|||
struct PushActivity
|
||||
{
|
||||
const ActivityId prevAct;
|
||||
PushActivity(ActivityId act) : prevAct(curActivity) { curActivity = act; }
|
||||
~PushActivity() { curActivity = prevAct; }
|
||||
PushActivity(ActivityId act) : prevAct(getCurActivity()) { setCurActivity(act); }
|
||||
~PushActivity() { setCurActivity(prevAct); }
|
||||
};
|
||||
|
||||
extern Logger * logger;
|
||||
|
|
Loading…
Reference in a new issue