Stricter Thread<> interface

Implements a Thread<>::invoke interface that only permits calling
member functions with bound arguments.

Also introduce invokeWithResult, which accepts a callback and invokes
it, passing the result, on the invoking thread's RunLoop. This closes
the loop of two evented threads doing message passing.
This commit is contained in:
John Firebaugh
2015-04-13 16:41:37 -07:00
parent 1066504008
commit 1eaf6b8c18
9 changed files with 237 additions and 137 deletions

View File

@@ -3,6 +3,28 @@
#include <uv.h>
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
int uv_key_create(uv_key_t* key) {
return -pthread_key_create(key, NULL);
}
void uv_key_delete(uv_key_t* key) {
if (pthread_key_delete(*key))
abort();
}
void* uv_key_get(uv_key_t* key) {
return pthread_getspecific(*key);
}
void uv_key_set(uv_key_t* key, void* value) {
if (pthread_setspecific(*key, value))
abort();
}
#endif
namespace uv {
std::string cwd() {