view codegear/StartCodeGear.cs @ 71:1169915705ab default tip

fix TopologyNode connect
author KaitoMaeshiro <aosskaito@cr.ie.u-ryukyu.ac.jp>
date Sun, 06 Feb 2022 16:47:41 +0900
parents 96fc5e71274e
children
line wrap: on
line source

using System.Collections.Concurrent;
using System.Threading;
using Christie_net.daemon;

namespace Christie_net.codegear {
public abstract class StartCodeGear : CodeGear {
    private static ConcurrentDictionary<int, CodeGearManager> cgmList = new ConcurrentDictionary<int, CodeGearManager>();
    private static ThreadPoolExecutors threadPoolExecutors = new ThreadPoolExecutors();
    private static int cgmCount = 1;

    public StartCodeGear(CodeGearManager cgm) {
        cgm.Setup(this);
    }

    public static CodeGearManager CreateCgm(int localPort) {
        CodeGearManager cgm = new CodeGearManager(cgmCount, threadPoolExecutors, cgmList, localPort);
        cgmList.TryAdd(cgmCount++, cgm);
        return cgm;
    }

    public static CodeGearManager GetCgm(int number) {
        return cgmList[number];
    }

    public override void Run(CodeGearManager cgm) {
        
    }
}
}