Ivan,
I completely agree with you about the need to keep platform dependent code (e.g. WinApi)
separate from the generic BlackBox framework. All such platform dependent code
should only exist in a Host subsystem.
-Doug
Robert wrote:I hope not. It looks like a very interesting proposal I am keen to have available (in a stable release) quickly; even if the initial proposal does ultimately prove to be a bit immature.Ivan Denisov wrote:What if we keep this issue for BlackBox 1.8 ?
Ivan Denisov wrote:If I understand Dmitry correct:
- Transfer should be forbidden in not main coroutine (now this has effect of GOTO operator)
- To return control to main coroutine Yeild procedure without arguments should be used...
- we should move WinApi calls to HostCoroutines module to provide "Equal opportunities" for realizations.
luowy wrote:I think we need some examples to measure our coroutine's efficiency
compare with other language or paltform, like node.js, dotnet
e.g thousands clients connect to server(net or files)
Is that possible at moment?
PROCEDURE Transfer* (target: Coroutine);
BEGIN
ASSERT(target.state = suspended, 20); (* => target # current *)
ASSERT(current = main, 21);
current.state := suspended;
target.source := current;
target.state := running;
current := target;
Kernel.TransferCoroutine(target.impl)
END Transfer;
PROCEDURE (this: Iterator) Yield*, NEW;
BEGIN
ASSERT(this.parent.state = suspended, 20);
current.state := suspended;
this.parent.source := current;
this.parent.state := running;
current := this.parent;
Kernel.TransferCoroutine(this.parent.impl);
ASSERT(this.source = this.parent, 80)
END Yield;
TYPE
Iterator = POINTER TO RECORD (Coroutines.Iterator)
next: INTEGER
END;
PROCEDURE (this: Iterator) Run;
VAR i: INTEGER;
BEGIN
StdLog.String("BEGIN Iterator"); StdLog.Ln;
FOR i := 0 TO 9 DO
this.next := i; this.Yield
END;
StdLog.String("END Iterator"); StdLog.Ln
END Run;
PROCEDURE RunPlainIterator*;
VAR it: Iterator;
BEGIN
NEW(it); Coroutines.Init(it);
Coroutines.Transfer(it);
WHILE it.state = Coroutines.suspended DO
StdLog.String("next ="); StdLog.Int(it.next); StdLog.Ln;
Coroutines.Transfer(it)
END
END RunPlainIterator;
repeat
if peek() then
res:=read(buf);
if res = ok then task.state :=sucessed
elsif res = error then task.state := failed
end;
else
inc(time or count);
if time or count >= max then task.state:= failed
else
(* Action.DoLater() without coroutine*)
coroutine.transfer(target); or coroutine.sleep(ms);
end;
end;
until task.state IN {sucessed,failed}
luowy wrote:yes, I known your fiber solution is efficient; the Co_ auther have given us a show about it;
what I want to know is the efficiency of "Task" solution base coroutine:
the other language like js, c# use 'Promise' or "Task" as base of async/await syntax sugar,
and the "Task" base coroutine switch; it have proven to be a good solution for concurrent task;
Users browsing this forum: No registered users and 0 guests