Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to the F# API for actor objects #702

Merged
merged 2 commits into from
Mar 3, 2015
Merged

Conversation

jorgef
Copy link
Contributor

@jorgef jorgef commented Mar 2, 2015

Added spawnObj and spawnObjOpt to support creating OO actors from F#.

Usage:

spawnObj mailbox.Context "tailActor" (<@ (fun () -> new TailActor(reporter, filePath)) @>)
spawnObjOpt mailbox.Context "tailActor" (<@ (fun () -> new TailActor(reporter, filePath)) @> ) [SpawnOption.SupervisorStrategy(SupervisorStrategy.DefaultStrategy)]

This is required to create actors that are able to handle methods like PreStart() and PostStop(). Without this there is no easy way to release disposable resources at the moment.

@rogeralsing
Copy link
Contributor

This has some overlap with this PR
#682

@Horusiath
Copy link
Contributor

@jorgef I think, I found another solution for problem of releasing IDisposable resources with #682 (new Defer method for Actor<'t> interface). Your commit however will greatly simplify life for F#-ers, who for some reasons want to use standard Actor API for their needs.

I'll review it soon.

/// <param name="name">Name of spawned child actor</param>
/// <param name="f">Used to create a new instance of the actor</param>
/// <param name="options">List of options used to configure actor creation</param>
let spawnObjOpt<'Actor when 'Actor :> ActorBase> (actorFactory : ActorRefFactory) (name : string) (f : Quotations.Expr<(unit -> 'Actor)>)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case <'Actor when 'Actor :> ActorBase> is unnecessary. Equivalent function signature is:
let spawnObjOpt (actorFactory : ActorRefFactory) (name : string) (f : Quotations.Expr<(unit -> #ActorBase)>)

This applies also to spawnObj function and documentation signatures.

@jorgef
Copy link
Contributor Author

jorgef commented Mar 2, 2015

@Horusiath I will have a look to #682 and try to use it whenever I can.
Thanks for the review, you are right, I just improved both signatures.

Horusiath added a commit that referenced this pull request Mar 3, 2015
Added support to the F# API for actor objects
@Horusiath Horusiath merged commit f319c27 into akkadotnet:dev Mar 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants