shared
This commit is contained in:
parent
f9f524fed1
commit
6567d7d912
@ -123,6 +123,7 @@ extern int path_fileprops(const std::string path, struct PathStat *stp,
|
|||||||
extern std::string path_PATHsep();
|
extern std::string path_PATHsep();
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include <memory>
|
||||||
bool wchartoutf8(const wchar_t *in, std::string& out, size_t len = 0);
|
bool wchartoutf8(const wchar_t *in, std::string& out, size_t len = 0);
|
||||||
std::string wchartoutf8(const wchar_t *in, size_t len = 0);
|
std::string wchartoutf8(const wchar_t *in, size_t len = 0);
|
||||||
bool utf8towchar(const std::string& in, wchar_t *out, size_t obytescap);
|
bool utf8towchar(const std::string& in, wchar_t *out, size_t obytescap);
|
||||||
|
|||||||
@ -72,6 +72,16 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Task deleter
|
||||||
|
* If put() is called with the flush option, and the tasks allocate memory,
|
||||||
|
* you need to set this function, which will be called on each task popped
|
||||||
|
* from the queue. Tasks which go through normally must be freed by the
|
||||||
|
* worker function.
|
||||||
|
*/
|
||||||
|
void setTaskFreeFunc(void (*func)(T&)) {
|
||||||
|
m_taskfreefunc = func;
|
||||||
|
}
|
||||||
|
|
||||||
/** Start the worker threads.
|
/** Start the worker threads.
|
||||||
*
|
*
|
||||||
* @param nworkers number of threads copies to start.
|
* @param nworkers number of threads copies to start.
|
||||||
@ -120,6 +130,10 @@ public:
|
|||||||
}
|
}
|
||||||
if (flushprevious) {
|
if (flushprevious) {
|
||||||
while (!m_queue.empty()) {
|
while (!m_queue.empty()) {
|
||||||
|
if (m_taskfreefunc) {
|
||||||
|
T& d = m_queue.front();
|
||||||
|
m_taskfreefunc(d);
|
||||||
|
}
|
||||||
m_queue.pop();
|
m_queue.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,6 +339,7 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void (*m_taskfreefunc)(T&){nullptr};
|
||||||
// Configuration
|
// Configuration
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
size_t m_high;
|
size_t m_high;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user