Skip to content

Commit

Permalink
fixes std and other
Browse files Browse the repository at this point in the history
  • Loading branch information
0xF6 committed Jul 9, 2024
1 parent 4c455c4 commit e7260e1
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 49 deletions.
52 changes: 44 additions & 8 deletions lib/vein.std/std/Testable.vein
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,51 @@
public class Testable
{
public static master(): Void
|> abobus(&delMethod);
{
auto c1 = Thread.Create(&cycle1);
auto c2 = Thread.Create(&cycle2);
auto c3 = Thread.Create(&cycle3);
while(true) {
Thread.Sleep(5000);
c1.Start();
Thread.Sleep(6000);
c2.Start();
c2.Join();
Out.print("FAILED JOIN");
Thread.Sleep(6000);
return;
}
}
public static cycle1(): void {
while(true) {
Out.print("cycle1");
Thread.Sleep(5000);
}
}

public static delMethod(i: i32): Void {
Out.print("calling delegate delMethod");
Out.print(i);
public static test(): void {
return;
}

public static abobus(fn: testMethod): Void
|> fn(255);
}
public static cycle2(): void {
auto i = 0;
while(true) {
i = i + 1;

if (i > 3)
{
return;
}
Out.print("cycle2");
Thread.Sleep(5000);
}
}

public static cycle3(): void {
while(true) {
Out.print("cycle3");
Thread.Sleep(2000);
}
}

global alias testMethod <| (i: i32): Void;
}
37 changes: 37 additions & 0 deletions lib/vein.std/std/Thread.vein
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#space "std"


public class Thread : Object
{
//[native("__internal__", "@_threading_begin_affinity")]
//public extern static BeginAffinity(): Void;
//[native("__internal__", "@_threading_end_affinity")]
//public extern static EndAffinity(): Void;
//[native("__internal__", "@_threading_begin_critical_region")]
//public extern static BeginCriticalRegion(): Void;
//[native("__internal__", "@_threading_end_critical_region")]
//public extern static EndCriticalRegion(): Void;
//[native("__internal__", "@_threading_memory_barrier")]
//public extern static MemoryBarrier(): Void;
//[native("__internal__", "@_threading_yield")]
//public extern static Yield(): Void;
[native("__internal__", "@_threading_create")]
public extern static Create(fn: ThreadFunction): Thread;
[native("__internal__", "@_threading_sleep")]
public extern static Sleep(ms: i32): void;

private _fn: ThreadFunction;
private _threadRef: raw;

public Join(): void
|> Thread._join(this);
public Start(): void
|> Thread._start(this);

[native("__internal__", "@_threading_join")]
private extern static _join(thread: Thread): void;
[native("__internal__", "@_threading_start")]
private extern static _start(thread: Thread): void;
}

global alias ThreadFunction <| (): void;
37 changes: 0 additions & 37 deletions lib/vein.std/std/Thread.vein_

This file was deleted.

File renamed without changes.
File renamed without changes.
19 changes: 16 additions & 3 deletions runtime/ishtar.vm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@

var vm = VirtualMachine.Create("app");
var vault = vm.Vault;


#if DEBUG
Thread.CurrentThread.Name = $"ishtar::entry";
#endif

var masterModule = default(IshtarAssembly);
var resolver = default(AssemblyResolver);

Expand Down Expand Up @@ -58,10 +62,19 @@
var frame = CallFrame.Create(entry_point, null);
frame->args = args_;


var watcher = Stopwatch.StartNew();

entry_point->ForceSetAsAsync();
//var debugModules = new DirectoryInfo("./modules");

//if (!debugModules.Exists)
// debugModules.Create();

//IshtarSharedDebugData.DumpToFile(new FileInfo($"./modules/{module->Name}.module"), IshtarTrace.Dump(module));

//module->deps_table->ForEach(x =>
//{
// IshtarSharedDebugData.DumpToFile(new FileInfo($"./modules/{x->Name}.module"), IshtarTrace.Dump(x));
//});

vm.task_scheduler->start_threading(module);
vm.task_scheduler->execute_method(frame);
Expand Down
2 changes: 1 addition & 1 deletion vein_lang.sln
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ishtar.vm.libuv", "runtime\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vein.std", "lib\vein.std\vein.std.csproj", "{4630487E-D9EA-4B62-A677-B8F0CDB3831F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ishtar.debug", "lib\ishtar.debug.console\ishtar.debug.csproj", "{17D286DB-1DF3-4280-8852-CED37FF50006}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ishtar.debug", "lib\ishtar.debug.console\ishtar.debug.csproj", "{17D286DB-1DF3-4280-8852-CED37FF50006}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down

0 comments on commit e7260e1

Please sign in to comment.