src/fiber.hpp
author Tero Marttila <terom@fixme.fi>
Fri, 18 Jul 2008 21:59:53 +0300
changeset 11176 874f8008e6e5
parent 10429 1b99254f9607
permissions -rw-r--r--
have ShowNewGRFDownload make a copy of the GRFConfig list containg only the relevant GRFConfigs
10175
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
     1
/* $Id$ */
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
     2
10429
1b99254f9607 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 10175
diff changeset
     3
/** @file fiber.hpp Base for all fiber related classes. */
10175
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
     4
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
     5
#ifndef FIBER_HPP
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
     6
#define FIBER_HPP
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
     7
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
     8
typedef void (CDECL *FiberFunc)(void *);
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
     9
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    10
class Fiber {
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    11
public:
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    12
	/**
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    13
	 * Switch to this fiber.
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    14
	 */
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    15
	virtual void SwitchToFiber() = 0;
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    16
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    17
	/**
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    18
	 * Exit a fiber.
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    19
	 */
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    20
	virtual void Exit() = 0;
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    21
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    22
	/**
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    23
	 * Check if a fiber is running.
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    24
	 */
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    25
	virtual bool IsRunning() = 0;
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    26
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    27
	/**
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    28
	 * Get the 'param' data of the Fiber.
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    29
	 */
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    30
	virtual void *GetFiberData() = 0;
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    31
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    32
	/**
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    33
	 * Virtual Destructor to mute warnings.
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    34
	 */
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    35
	virtual ~Fiber() {};
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    36
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    37
	/**
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    38
	 * Create a new fiber, calling proc(param) when running.
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    39
	 */
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    40
	static Fiber *New(FiberFunc proc, void *param);
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    41
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    42
	/**
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    43
	 * Attach a current thread to a new fiber.
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    44
	 */
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    45
	static Fiber *AttachCurrent(void *param);
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    46
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    47
	/**
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    48
	 * Get the 'param' data of the current active Fiber.
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    49
	 */
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    50
	static void *GetCurrentFiberData();
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    51
};
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    52
1119f6640ee6 (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
rubidium
parents:
diff changeset
    53
#endif /* FIBER_HPP */