[Issue 12090] Make std.concurrency compatible with fibers as threads

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 9 07:15:20 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12090


Jakob Ovrum <jakobovrum at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakobovrum at gmail.com


--- Comment #2 from Jakob Ovrum <jakobovrum at gmail.com> 2014-02-09 07:15:04 PST ---
(In reply to comment #1)
> I think something like the following will work:
> 
> interface Scheduler
> {
>     void start(void delegate() op);
>     void spawn(void delegate() op);
>     void yield();
>     @property ref ThreadInfo thisInfo();
>     Condition newCondition(Mutex m);
> }
> 
> 
> When using a scheduler, main() should do any initial setup that it wants and
> then call scheduler.start(), which will effectively spawn the supplied delegate
> as a thread and then begin dispatching.
> 
> The remaining functions are all used by the std.concurrency implementation. 
> spawn() does the work of actually creating new threads, yield() will yield
> execution of the current fiber (or optionally, thread) so that multiprocessing
> can occur, and newCondition constructs a Condition object used by send() and
> receive() to indicate that a message has arrived, block waiting for a new
> message, etc.  Finally, ThreadInfo is needed so that the thread-local statics
> currently in std.concurrency can be made local to the "thread" currently
> executing.  If thisInfo is called by a thread or fiber not spawned by
> std.concurrency, it can return a thread-local copy instead.

It has been suggested that std.concurrency should also be able to support IPC
(most importantly by Andrei in the module's documentation). The proposed
Scheduler interface seems close to supporting that for fork()-based code (which
of course isn't an option for non-POSIX systems), but do you have any thoughts
on this?

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list