| 349 | === Alternative conduit entrances === |
| 350 | |
| 351 | To enhance performance, there are two alternative types of entrances: shared data entrances and asynchronous entrances. The first can be created with |
| 352 | {{{ |
| 353 | public void addPortals() { |
| 354 | entrance = addSharedDataEntrance("entranceName", double[].class); |
| 355 | } |
| 356 | }}} |
| 357 | When using a shared data entrance, MUSCLE will try to not copy the data that is sent through the conduit. This means that any change that is done by a conduit filter or another submodel that receives the data, also affects the original data. In most cases this is not desirable, since it violates the separation that different submodels have. Moreover, it is fragile since it only works if the sending and receiving submodel are in the same instance, and there is no filter applied that copies the data in some way. |
| 358 | |
| 359 | The shared data conduit entrance does make sense when the sending submodel will not use the sent data in any way, since then another submodels may modify it as it pleases. |
| 360 | |
| 361 | The second alternative conduit entrance is the asynchronous conduit entrance, which is created as |
| 362 | {{{ |
| 363 | entrance = addAsynchronousEntrance("entranceName", double[].class); |
| 364 | }}} |
| 365 | Whenever a message is sent through this type of entrance the sending submodel does not have to wait until the receiving MUSCLE instance has received the data. This mode of operation slightly increases the latency and involves keeping alive an additional thread. There can be a performance gain if the submodel that sends the data, afterwards immediately continues its computations and does not have to wait for input from another submodel. It may also speed up sending multiple messages shortly after each other. The gain will be larger if data is sent across multiple MUSCLE instances. |
| 366 | |
| 367 | Using the addAsynchronousEntrance call is equivalent to adding the conduit filter "thread" to the beginning of the conduit entrance filter stack, as explained in the [[Configuration|configuration section]]. |