Akka.Interfaced.HandlerBuilderHelpers.IsReentrantMethod C# (CSharp) Method

IsReentrantMethod() public static method

public static IsReentrantMethod ( MethodInfo method ) : bool
method System.Reflection.MethodInfo
return bool
        public static bool IsReentrantMethod(MethodInfo method)
        {
            return method.CustomAttributes.Any(x => x.AttributeType == typeof(ReentrantAttribute));
        }

Usage Example

Beispiel #1
0
        private void BuildAnnotatedMessageHandlers()
        {
            // create a handler for every method which has MessageHandlerAttribute

            var methods = _type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            foreach (var method in methods)
            {
                var attr = method.GetCustomAttribute <MessageHandlerAttribute>();
                if (attr == null)
                {
                    continue;
                }

                var messageType   = attr.Type ?? method.GetParameters()[0].ParameterType;
                var isAsyncMethod = (method.ReturnType.Name.StartsWith("Task"));
                var filterChain   = _filterHandlerBuilder.Build(method, FilterChainKind.Message);
                var isSyncHandler = isAsyncMethod == false && filterChain.AsyncFilterExists == false;
                var isReentrant   = isSyncHandler == false && HandlerBuilderHelpers.IsReentrantMethod(method);

                if (isAsyncMethod == false && method.GetCustomAttribute <AsyncStateMachineAttribute>() != null)
                {
                    throw new InvalidOperationException($"Async void handler is not supported. ({_type.FullName}.{method.Name})");
                }

                AddHandler(method, messageType, filterChain, isSyncHandler, isReentrant);
            }
        }
All Usage Examples Of Akka.Interfaced.HandlerBuilderHelpers::IsReentrantMethod