Object oriented Stackful coroutines library for Delphi and FreePascal

Object oriented Stackful coroutines library for Delphi and FreePascal version 2.03

Description:

This is an object oriented library to do Stackful Coroutines for FreePascal and Delphi and it comes with a semaphore and a mutex.

Because threads alone are expensive on windows because each

thread can take one Megabytes of stack and the thread context

switch is expensive, so you can use this library with my Threadpool engine that scales well to be able to serve a great number of internet connections or TCP/IP socket connections, and of course you can do with it many other things such as simulations etc.

Here is the use cases of this object oriented coroutines library:

- Context switching is expensive with threads, with coroutines it is

really fast.

- My mutex and semaphore of my coroutines library are much much more faster than the mutex and semaphore used on processes and threads.

Main features:

Very small RAM overhead and provides semaphore and mutex.

Note: I have not saved the XMM registers on 64 bit compilers in my assembler routines, so with fastcall calling convention you have to pass the floating-point arguments by reference or use dynamic memory.

I have come to an interesting subject...

Is my Object coroutines library still useful ?

Can threads do the same job as coroutines ?

I think that coroutines are still useful because a lock or a cache-line transfer is expensive on threads running on multicores, a cache-line transfer between cores is around 800 CPU cycles on x86 , and that's too much expensive compared to coroutines, and the semaphore and mutex of my coroutines library and the contention on them are thus much much less expensive, other than that coroutines can yield to other functions or procedures inside a function or procedure, so i think that coroutines are thus still useful.

Look at the defines.inc include file, you can configure it like this:

{$DEFINE XE} for Delphi XE compilers and Delphi tokyo.

{$DEFINE FPC} for FreePascal.

{$DEFINE Delphi} for Delphi 7 to Delphi 2007 compilers.

{$DEFINE CPU32} for 32 bit systems

{$DEFINE CPU64} for 64 bit systems

Language: FPC Pascal v2.2.0+ / Delphi 5+: http://www.freepascal.org/

Operating Systems: Win, Mac OS X and Linux on (x86).

Please click on the small arrow on the right of the zip file bellow to download...