diff options
author | Pixel <pixel@nobis-crew.org> | 2011-10-18 16:37:49 -0700 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2011-10-18 16:37:49 -0700 |
commit | 0db120afdfb818421dc5df3dc0946fafede78c93 (patch) | |
tree | e47403f57bcc39471d6c994c4f2951f4eb9ba108 /includes | |
parent | 4e07ceeb21dae4b6b8d5eaf7421228f735f14bda (diff) |
libcoro seems to be doing really spurious things when not using the standard functions.
Switching out libcoro for the native Fibers interface for Win32.
Switching out the asm version for the ucontext version for Linux.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/Task.h | 12 | ||||
-rw-r--r-- | includes/TaskMan.h | 6 |
2 files changed, 17 insertions, 1 deletions
diff --git a/includes/Task.h b/includes/Task.h index 042624d..b124731 100644 --- a/includes/Task.h +++ b/includes/Task.h @@ -1,7 +1,9 @@ #pragma once #include <stdlib.h> +#ifndef _WIN32 #include <coro.h> +#endif #include <ev++.h> #include <vector> #include <Exceptions.h> @@ -81,6 +83,10 @@ class Async : public BaseEvent { ev::async m_evt; }; +#ifndef _WIN32 +#define CALLBACK +#endif + class Custom : public BaseEvent { public: void doSignal() { BaseEvent::doSignal(); ev_break(m_loop, EVBREAK_ALL); } @@ -137,9 +143,13 @@ class Task { private: size_t stackSize() { return 128 * 1024; } void switchTo(); - static void coroutine(void *); + static void CALLBACK coroutine(void *); void * m_stack; +#ifndef _WIN32 coro_context m_ctx; +#else + void * m_fiber; +#endif TaskMan * m_taskMan; Status m_status; void * m_tls; diff --git a/includes/TaskMan.h b/includes/TaskMan.h index 8144e93..ad19f65 100644 --- a/includes/TaskMan.h +++ b/includes/TaskMan.h @@ -1,7 +1,9 @@ #pragma once #include <stdint.h> +#ifndef _WIN32 #include <coro.h> +#endif #include <ev++.h> #include <ext/hash_set> #include <vector> @@ -26,7 +28,11 @@ class TaskMan { private: void registerTask(Task * t); void unregisterTask(Task * t); +#ifndef _WIN32 coro_context m_returnContext; +#else + void * m_fiber; +#endif friend class Task; struct taskHasher { size_t operator()(const Task * t) const { return reinterpret_cast<uintptr_t>(t); } }; typedef gnu::hash_set<Task *, taskHasher> taskHash_t; |