src/fiber.hpp
author truebrain
Mon, 23 Jun 2008 13:52:21 +0000
branchnoai
changeset 11058 3305a425f55b
parent 10455 22c441f5adf9
permissions -rw-r--r--
(svn r13615) [NoAI] -Fix: fixed most, if not all, problems around AIAbstractList. It is now safe to remove values while looping, among other things.
[NoAI] -Add: allow foreach() usage for AIAbstractList
[NoAI] -Add: allow [] usage for AIAbstractList (read-only)
[NoAI] -Add: allow [] usage for AIList (read/write)
/* $Id$ */

/** @file fiber.hpp Base for all fiber related classes. */

#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 */