@@ -16,7 +16,7 @@ type ActorHandle interface {
1616type ActorDef struct {
1717 id time.Time
1818 isClosed bool
19- ch * chan interface {}
19+ ch chan interface {}
2020 effect func (* ActorDef , interface {})
2121
2222 context map [string ]interface {}
@@ -34,12 +34,11 @@ func (actorSelf *ActorDef) GetDefault() *ActorDef {
3434
3535// New New Actor instance
3636func (actorSelf * ActorDef ) New (effect func (* ActorDef , interface {})) * ActorDef {
37- ch := make (chan interface {})
38- return actorSelf .NewByOptions (effect , & ch , map [string ]interface {}{})
37+ return actorSelf .NewByOptions (effect , make (chan interface {}), map [string ]interface {}{})
3938}
4039
4140// NewByOptions New Actor by its options
42- func (actorSelf * ActorDef ) NewByOptions (effect func (* ActorDef , interface {}), ioCh * chan interface {}, context map [string ]interface {}) * ActorDef {
41+ func (actorSelf * ActorDef ) NewByOptions (effect func (* ActorDef , interface {}), ioCh chan interface {}, context map [string ]interface {}) * ActorDef {
4342 newOne := ActorDef {
4443 id : time .Now (),
4544 ch : ioCh ,
@@ -58,7 +57,7 @@ func (actorSelf *ActorDef) Send(message interface{}) {
5857 return
5958 }
6059
61- * ( actorSelf .ch ) <- message
60+ actorSelf .ch <- message
6261}
6362
6463// Spawn Spawn a new Actor with parent(this actor)
@@ -93,7 +92,7 @@ func (actorSelf *ActorDef) GetID() time.Time {
9392func (actorSelf * ActorDef ) Close () {
9493 actorSelf .isClosed = true
9594
96- close (* actorSelf .ch )
95+ close (actorSelf .ch )
9796}
9897
9998// IsClosed Check is Closed
@@ -102,7 +101,7 @@ func (actorSelf *ActorDef) IsClosed() bool {
102101}
103102
104103func (actorSelf * ActorDef ) run () {
105- for message := range * actorSelf .ch {
104+ for message := range actorSelf .ch {
106105 actorSelf .effect (actorSelf , message )
107106 }
108107}
@@ -113,7 +112,7 @@ var Actor ActorDef
113112// AskDef Ask inspired by Erlang/Akka
114113type AskDef struct {
115114 id time.Time
116- ch * chan interface {}
115+ ch chan interface {}
117116
118117 Message interface {}
119118}
@@ -124,18 +123,17 @@ func (askSelf *AskDef) New(message interface{}) *AskDef {
124123}
125124
126125// NewByOptions New Ask by its options
127- func (askSelf * AskDef ) NewByOptions (message interface {}, ioCh * chan interface {}) * AskDef {
126+ func (askSelf * AskDef ) NewByOptions (message interface {}, ioCh chan interface {}) * AskDef {
128127 return AskNewByOptionsGenerics (message , ioCh )
129128}
130129
131130// AskNewGenerics New Ask instance
132131func AskNewGenerics (message interface {}) * AskDef {
133- ch := make (chan interface {})
134- return AskNewByOptionsGenerics (message , & ch )
132+ return AskNewByOptionsGenerics (message , make (chan interface {}))
135133}
136134
137135// AskNewByOptionsGenerics New Ask by its options
138- func AskNewByOptionsGenerics (message interface {}, ioCh * chan interface {}) * AskDef {
136+ func AskNewByOptionsGenerics (message interface {}, ioCh chan interface {}) * AskDef {
139137 newOne := AskDef {
140138 id : time .Now (),
141139 ch : ioCh ,
@@ -149,14 +147,14 @@ func AskNewByOptionsGenerics(message interface{}, ioCh *chan interface{}) *AskDe
149147// AskOnce Sender Ask
150148func (askSelf * AskDef ) AskOnce (target ActorHandle , timeout * time.Duration ) (interface {}, error ) {
151149 ch := askSelf .AskChannel (target )
152- defer close (* ch )
150+ defer close (ch )
153151 var result interface {}
154152 // var err error
155153 if timeout == nil {
156- result = <- * ch
154+ result = <- ch
157155 } else {
158156 select {
159- case result = <- * ch :
157+ case result = <- ch :
160158 case <- time .After (* timeout ):
161159 return result , ErrActorAskTimeout
162160 }
@@ -166,15 +164,15 @@ func (askSelf *AskDef) AskOnce(target ActorHandle, timeout *time.Duration) (inte
166164}
167165
168166// AskChannel Sender Ask
169- func (askSelf * AskDef ) AskChannel (target ActorHandle ) * chan interface {} {
167+ func (askSelf * AskDef ) AskChannel (target ActorHandle ) chan interface {} {
170168 target .Send (askSelf )
171169
172170 return askSelf .ch
173171}
174172
175173// Reply Receiver Reply
176174func (askSelf * AskDef ) Reply (response interface {}) {
177- * askSelf .ch <- response
175+ askSelf .ch <- response
178176}
179177
180178// Ask Ask utils instance
0 commit comments