Skip to content

Commit

Permalink
A bit refactoring pools related stuff and bumping up a version
Browse files Browse the repository at this point in the history
  • Loading branch information
pachanga committed Nov 30, 2024
1 parent 9fb1979 commit a2accaf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
26 changes: 13 additions & 13 deletions src/vm/util/refc_list.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace bhl {

Expand All @@ -13,22 +14,21 @@ public class RefcList<T> : List<T>, IValRefcounted, IDisposable

public int refs => _refs;

static class PoolHolder<T1>
{
[ThreadStatic]
static public Pool<RefcList<T1>> _pool;
public static Pool<RefcList<T1>> pool {
get {
if(_pool == null)
_pool = new Pool<RefcList<T1>>();
return _pool;
}
}
}

[ThreadStatic]
static Pool<RefcList<T>> _pool;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
static Pool<RefcList<T>> GetPool()
{
if(_pool == null)
_pool = new Pool<RefcList<T>>();
return _pool;
}

static public RefcList<T> New()
{
var pool = PoolHolder<T>.pool;
var pool = GetPool();

RefcList<T> list = null;
if(pool.stack.Count == 0)
Expand Down
20 changes: 9 additions & 11 deletions src/vm/util/val_list_adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,20 @@ public class ValList<T> : IList<T>, IValRefcounted, IDisposable

public int refs => _refs;

static class PoolHolder<T1>
[ThreadStatic]
static Pool<ValList<T>> _pool;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
static Pool<ValList<T>> GetPool()
{
[ThreadStatic]
static public Pool<ValList<T1>> _pool;
public static Pool<ValList<T1>> pool {
get {
if(_pool == null)
_pool = new Pool<ValList<T1>>();
return _pool;
}
}
if(_pool == null)
_pool = new Pool<ValList<T>>();
return _pool;
}

static public ValList<T> New(ValList lst, Func<Val, T> val2native)
{
var pool = PoolHolder<T>.pool;
var pool = GetPool();

ValList<T> vls = null;
if(pool.stack.Count == 0)
Expand Down
2 changes: 1 addition & 1 deletion src/vm/version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace bhl {

public static class Version
{
public static string Name = "v2.0.0-beta193";
public static string Name = "v2.0.0-beta194";
}

}

0 comments on commit a2accaf

Please sign in to comment.