designing an actor model game architecture with pony

19
Designing an Actor Model Game Architecture with Pony Nick Prühs

Upload: nick-pruehs

Post on 13-Jan-2017

60 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Designing an actor model game architecture with Pony

Designing an Actor Model Game Architecture with PonyNick Prühs

Page 2: Designing an actor model game architecture with Pony
Page 3: Designing an actor model game architecture with Pony

Pony

• object-oriented

• actor-model

• capabilities-secure

Page 4: Designing an actor model game architecture with Pony

Pony

• object-oriented

• actor-model

• capabilities-secure

Page 5: Designing an actor model game architecture with Pony

Hello world!

actor Mainnew create(env: Env) =>

env.out.print("Hello, world!")

Page 6: Designing an actor model game architecture with Pony

Actors in Pony

• Similar to classes

• Can have asynchronous functions called behaviours

• Bodies of behaviours will execute at some indeterminate time in the

future

• All behaviours always return the receiver

They can't return something they calculate (since they haven't

run yet)

Returning the receiver is a convenience to allow chaining calls

on the receiver

Page 7: Designing an actor model game architecture with Pony

Behaviours

actor Aardvark

let name: String

var _hunger_level: U64 = 0

new create(name': String) =>

name = name'

be eat(amount: U64) =>

_hunger_level = _hunger_level - amount.min(_hunger_level)

Page 8: Designing an actor model game architecture with Pony

“Here we have an Aardvark that can eat asynchronously.

Clever Aardvark.”

Page 9: Designing an actor model game architecture with Pony

Pony

• object-oriented

• actor-model

• capabilities-secure

Page 10: Designing an actor model game architecture with Pony

Reference Capabilities

Remember const in C++?

Page 11: Designing an actor model game architecture with Pony

Reference Capabilities

Remember const in C++?

Awesome, right?

Page 12: Designing an actor model game architecture with Pony

Reference Capabilities

• ref – mutable

• val - immutable

• iso - no one else can read or write

… plus three more.

Page 13: Designing an actor model game architecture with Pony

Reference Capabilities

actor FileStream is OutStream

let _file: File

new create(file: File iso) =>

_file = consume file

be write(data: ByteSeq) =>

_file.write(data)

Page 14: Designing an actor model game architecture with Pony

Pony

• type safe

• memory safe

• exception safe

• data-race free

• deadlock free

Page 15: Designing an actor model game architecture with Pony

PonyGame Architecture

Page 16: Designing an actor model game architecture with Pony

DEMO

Page 17: Designing an actor model game architecture with Pony

Code publicly available at

https://github.com/npruehs/pony-game

Page 18: Designing an actor model game architecture with Pony

References

• S. Clebsch, Pony: Co-Designing a Type System and a Runtime.Microsoft Research, Cambridge, 2016.

• S. T Allen, S. Clebsch, S. Blessing, A. McNeil et al., Pony Tutorial.http://tutorial.ponylang.org, 2016.

• S. Clebsch, S. Blessing, J. Franco, S. Drossopoulou, Ownership and Reference Counting based Garbage Collection in the Actor World.Causality Ltd. and Imperial College London, 2015.

• S. Clebsch, S. Drossopoulou, Fully Concurrent Garbage Collection of Actors on Many-Core Machines. OOPSLA 2013.

• S. Clebsch, S. Drossopoulou, S. Blessing, A. McNeil, Deny Capabilities for Safe, Fast Actors. Causality Ltd. and Imperial College London.

Page 19: Designing an actor model game architecture with Pony

Thank you for listening!

https://github.com/npruehs

@npruehs

[email protected]