You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Pavel Tupitsyn (JIRA)" <ji...@apache.org> on 2016/09/07 15:47:20 UTC

[jira] [Comment Edited] (IGNITE-1894) .NET: Delegate support in the API via extension methods

    [ https://issues.apache.org/jira/browse/IGNITE-1894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15470889#comment-15470889 ] 

Pavel Tupitsyn edited comment on IGNITE-1894 at 9/7/16 3:46 PM:
----------------------------------------------------------------

Different implementation idea:

Use expression trees instead of raw delegates, for example:
{code}
public static TRes Call2<TRes>(this ICompute compute, Expression<Func<TRes>> func)
{code}

This is very cool: users won't have to ship DLLs to remote nodes! We'll serialize the expression and compile it on the other end. 
This is some kind of "Peer class loading lite" - limited, but easy to implement and easy on resources.

Considerations:
* Expressions have more limits than raw delegates
* Expressions are not serializable. However, Ignite reflective serializer seems to handle them just fine.

I've did a quick test, with dynamic registration (IGNITE-2703) this approach works.


was (Author: ptupitsyn):
Different implementation idea:

Use expression trees instead of raw delegates, for example:
{code}
public static TRes Call2<TRes>(this ICompute compute, Expression<Func<TRes>> func)
{code}

This is very cool: users won't have to ship DLLs to remote nodes! We'll serialize the expression and compile it on the other end. 
This is some kind of "Peer class loading lite" - limited, but easy to implement and easy on resources.

Considerations:
* Expressions have more limits than raw delegates
* Expressions are not serializable. We'll have to use a third-party lib (https://github.com/mcintyre321/metalinq, http://expressiontree.codeplex.com/) or roll our own. 

> .NET: Delegate support in the API via extension methods
> -------------------------------------------------------
>
>                 Key: IGNITE-1894
>                 URL: https://issues.apache.org/jira/browse/IGNITE-1894
>             Project: Ignite
>          Issue Type: Improvement
>          Components: platforms
>    Affects Versions: 1.1.4
>            Reporter: Pavel Tupitsyn
>            Assignee: Pavel Tupitsyn
>            Priority: Minor
>              Labels: .net, roadmap
>             Fix For: 2.0
>
>
> In many places we require a single-method interface implementation from the user:
> {code:title=ICompute}
> TRes Call<TRes>(IComputeFunc<TRes> clo);
> {code}
> All of these can be extended to accept a delegate:
> {code:title=ICompute}
> TRes Call<TRes>(Func<TRes> clo);
> {code}
> We can't replace interfaces with delegates completely (which is desirable), because it will take away serialization control from the user. So the interface approach has to stay as a primary.
> Delegate support can be added via extension methods, which wrap provided delegates into a class that implements corresponding interface.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)