diff options
author | rubidium <rubidium@openttd.org> | 2008-04-14 19:54:33 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-04-14 19:54:33 +0000 |
commit | d022d4af3d8b64e06484cfb05e3d6e8b94f3d200 (patch) | |
tree | a38226d767be0babf008f3304e7a61a4a00af2aa /src/fiber.hpp | |
parent | bf1d42c23d9c7249d63edd953339af9e6acc9b0d (diff) | |
download | openttd-d022d4af3d8b64e06484cfb05e3d6e8b94f3d200.tar.xz |
(svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
Diffstat (limited to 'src/fiber.hpp')
-rw-r--r-- | src/fiber.hpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/fiber.hpp b/src/fiber.hpp new file mode 100644 index 000000000..3ea776d5c --- /dev/null +++ b/src/fiber.hpp @@ -0,0 +1,53 @@ +/* $Id$ */ + +/** @file fiber.hpp */ + +#ifndef FIBER_HPP +#define FIBER_HPP + +typedef void (CDECL *FiberFunc)(void *); + +class Fiber { +public: + /** + * Switch to this fiber. + */ + virtual void SwitchToFiber() = 0; + + /** + * Exit a fiber. + */ + virtual void Exit() = 0; + + /** + * Check if a fiber is running. + */ + virtual bool IsRunning() = 0; + + /** + * Get the 'param' data of the Fiber. + */ + virtual void *GetFiberData() = 0; + + /** + * Virtual Destructor to mute warnings. + */ + virtual ~Fiber() {}; + + /** + * Create a new fiber, calling proc(param) when running. + */ + static Fiber *New(FiberFunc proc, void *param); + + /** + * Attach a current thread to a new fiber. + */ + static Fiber *AttachCurrent(void *param); + + /** + * Get the 'param' data of the current active Fiber. + */ + static void *GetCurrentFiberData(); +}; + +#endif /* FIBER_HPP */ |