designing an actor model game architecture with pony

Post on 13-Jan-2017

60 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Designing an Actor Model Game Architecture with PonyNick Prühs

Pony

• object-oriented

• actor-model

• capabilities-secure

Pony

• object-oriented

• actor-model

• capabilities-secure

Hello world!

actor Mainnew create(env: Env) =>

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

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

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)

“Here we have an Aardvark that can eat asynchronously.

Clever Aardvark.”

Pony

• object-oriented

• actor-model

• capabilities-secure

Reference Capabilities

Remember const in C++?

Reference Capabilities

Remember const in C++?

Awesome, right?

Reference Capabilities

• ref – mutable

• val - immutable

• iso - no one else can read or write

… plus three more.

Reference Capabilities

actor FileStream is OutStream

let _file: File

new create(file: File iso) =>

_file = consume file

be write(data: ByteSeq) =>

_file.write(data)

Pony

• type safe

• memory safe

• exception safe

• data-race free

• deadlock free

PonyGame Architecture

DEMO

Code publicly available at

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

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.

Thank you for listening!

https://github.com/npruehs

@npruehs

nick.pruehs@daedalic.com

top related