Esempio n. 1
0
        internal Chan <T> GetOrCreate <T>() where T : struct
        {
            lock (lockObj)
            {
                var type = typeof(T);
                if (chs.ContainsKey(type))
                {
                    return((Chan <T>)chs[type]);
                }

                chs[type] = new Chan <T>();
                return((Chan <T>)chs[type]);
            }
        }
Esempio n. 2
0
        public WaitResultInstruction()
        {
            var ch = Chan <T> .Make();

            ch.Receive(
                (result, ok) =>
            {
                if (ok)
                {
                    _result = result;
                }
                _keepWaiting = false;
            }
                );
        }
Esempio n. 3
0
        internal bool IsExists <T>(out Chan <T> ch) where T : struct
        {
            lock (lockObj)
            {
                var type = typeof(T);
                if (chs.ContainsKey(type))
                {
                    ch = (Chan <T>)chs[type];
                    return(true);
                }

                ch = null;
                return(false);
            }
        }
Esempio n. 4
0
        public ForInstruction(Action <T> onReceive)
        {
            var ch = Chan <T> .Make();

            ch.Receive(
                (t, ok) =>
            {
                if (!ok)
                {
                    _keepWaiting = false;
                    return;
                }
                onReceive(t);
            }
                );
        }