@@ -27,6 +27,12 @@ The `actor-system` and the `actor` itself are composed of an `actor-context`."))
27
27
(defun %get-shared-dispatcher (system identifier)
28
28
(getf (asys :dispatchers system) identifier))
29
29
30
+ (defun %get-dispatcher-config (config dispatcher-id)
31
+ (let* ((disp-config (config :retrieve-section config :dispatchers ))
32
+ (dispatcher-keys (config :retrieve-keys disp-config)))
33
+ (when (find dispatcher-id dispatcher-keys)
34
+ (config :retrieve-section disp-config dispatcher-id))))
35
+
30
36
(defun %add-actor (context actor)
31
37
(let ((atomic-actors (slot-value context ' actors)))
32
38
(atomic :atomic-swap atomic-actors (lambda (old-actors)
@@ -43,16 +49,23 @@ The `actor-system` and the `actor` itself are composed of an `actor-context`."))
43
49
(act-cell :name actor))))
44
50
old-actors)))))
45
51
46
- (defun %message-box-for-dispatcher-id (context dispatcher-id queue-size)
52
+ (defun %message-box-for-dispatcher-id (context dispatcher-id queue-size mbox-type )
47
53
(case dispatcher-id
48
54
(:pinned (make-instance ' mesgb:message-box/bt
49
55
:max-queue-size queue-size))
50
- (otherwise (let ((dispatcher (%get-shared-dispatcher (system context) dispatcher-id)))
56
+ (otherwise (let* ((asys (system context))
57
+ (sys-config (asys :config asys))
58
+ (disp-config (%get-dispatcher-config sys-config dispatcher-id))
59
+ (dispatcher (%get-shared-dispatcher asys dispatcher-id)))
51
60
(unless dispatcher
52
61
(error (format nil " No such dispatcher identifier '~a ' exists!" dispatcher-id)))
53
- (make-instance ' mesgb:message-box/dp
54
- :dispatcher dispatcher
55
- :max-queue-size queue-size)))))
62
+ ; ; if dispatcher exists, the config does, too.
63
+ (let ((eff-mbox-type (if mbox-type
64
+ mbox-type
65
+ (getf disp-config :mbox-type ' mesgb:message-box/dp))))
66
+ (make-instance eff-mbox-type
67
+ :dispatcher dispatcher
68
+ :max-queue-size queue-size))))))
56
69
57
70
(defun %find-actor-by-name (context name)
58
71
(find-if (lambda (a)
@@ -75,19 +88,19 @@ The `actor-system` and the `actor` itself are composed of an `actor-context`."))
75
88
(log :error " Actor with name '~a ' already exists!" actor-name)
76
89
(error (make-condition ' actor-name-exists :name actor-name)))))
77
90
78
- (defun %create-actor (context create-fun dispatcher-id queue-size)
91
+ (defun %create-actor (context create-fun dispatcher-id queue-size mbox-type )
79
92
(let ((actor (funcall create-fun)))
80
93
(when actor
81
94
(%verify-actor context actor)
82
95
(act ::finalize-initialization actor
83
- (%message-box-for-dispatcher-id context dispatcher-id queue-size)
96
+ (%message-box-for-dispatcher-id context dispatcher-id queue-size mbox-type )
84
97
(make-actor-context (system context)
85
98
(miscutils :mkstr (id context) " /" (act-cell :name actor)))))
86
99
actor))
87
100
88
- (defun %actor-of (context create-fun &key (dispatcher :shared ) (queue-size 0 ))
101
+ (defun %actor-of (context create-fun &key (dispatcher :shared ) (queue-size 0 ) mbox-type )
89
102
" See `ac:actor-of`"
90
- (let ((created (%create-actor context create-fun dispatcher queue-size)))
103
+ (let ((created (%create-actor context create-fun dispatcher queue-size mbox-type )))
91
104
(when created
92
105
(act :watch created context)
93
106
(%add-actor context created))))
@@ -122,19 +135,22 @@ An `act:actor` contains an `actor-context`."
122
135
" See `ac:actor-of`."
123
136
(check-type receive function " a function!" )
124
137
125
- (alexandria :remove-from-plistf rest
126
- :queue-size
127
- :dispatcher )
128
- (%actor-of context
129
- (lambda () (apply #' act:make-actor receive
130
- :init init
131
- :destroy destroy
132
- :state state
133
- :type type
134
- :name name
135
- rest ))
136
- :dispatcher dispatcher
137
- :queue-size queue-size))
138
+ (let ((mbox-type (getf rest :mbox-type )))
139
+ (alexandria :remove-from-plistf rest
140
+ :queue-size
141
+ :dispatcher
142
+ :mbox-type )
143
+ (%actor-of context
144
+ (lambda () (apply #' act:make-actor receive
145
+ :init init
146
+ :destroy destroy
147
+ :state state
148
+ :type type
149
+ :name name
150
+ rest ))
151
+ :dispatcher dispatcher
152
+ :queue-size queue-size
153
+ :mbox-type mbox-type)))
138
154
139
155
140
156
; ; test 2-arity function with 'path' and 'act-cell-name' (default)
0 commit comments