Exemplo n.º 1
0
        public Type DefineParallelizedType(ModuleBuilder moduleBuilder)
        {
            TypeBuilder typeBuilder = moduleBuilder.DefineType(ParallelizedTypeName);
            typeBuilder.SetParent(source);

            TypeAnalyzer typeAnalyzer = new TypeAnalyzer(source);
            ChannelImplementer channelImplementer = new ChannelImplementer(typeBuilder);
            ForkImplementer forkImplementer = new ForkImplementer(typeBuilder, channelImplementer);
            ChordImplementer chordImplementer = new ChordImplementer(typeBuilder, channelImplementer);
            JoinImplementer joinImplementer = new JoinImplementer(typeBuilder, channelImplementer);
            YieldImplementer yieldImplementer = new YieldImplementer(typeBuilder, channelImplementer);
            DisposeImplementer disposeImplementer = new DisposeImplementer(typeBuilder, source);
            ConstructorImplementer constructorImplementer = new ConstructorImplementer(typeBuilder, source,
                                                                                       channelImplementer,
                                                                                       chordImplementer,
                                                                                       disposeImplementer);

            foreach (ForkGroup forkGroup in typeAnalyzer.GetForkGroups())
                forkImplementer.Implement(forkGroup);

            foreach (ChordInfo chord in typeAnalyzer.GetChords())
                chordImplementer.Implement(chord);

            foreach (JoinGroup joinGroup in typeAnalyzer.GetJoinGroups())
                joinImplementer.Implement(joinGroup);

            foreach (YieldInfo yieldInfo in typeAnalyzer.GetYields())
                yieldImplementer.Implement(yieldInfo);

            disposeImplementer.ImplementDisposalBehavior();
            constructorImplementer.ImplementConstructor();

            return typeBuilder.CreateType();
        }
Exemplo n.º 2
0
 public JoinImplementer(TypeBuilder target, ChannelImplementer channelImplementer)
 {
     this.target = target;
     this.channelImplementer = channelImplementer;
 }