You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Make sure the program doesn't end before the async task completes
238
+
sleep(60);
239
+
}
240
+
```
241
+
242
+
This approach can be useful for integrating with existing async/event systems like [libevent](https://libevent.org/) or [libuv](https://libuv.org/).
243
+
244
+
One of the caveats is that these callbacks are executed from within opaque Carton-owned threads. As a general rule, it's important to avoid doing blocking I/O or extended periods of CPU-bound work within these callbacks. Doing so could block other tasks within Carton's internal async runtime from executing.
245
+
246
+
To help ease these restrictions, we provide another approach with `CartonAsyncNotifier`. This lets users wait for or poll for new callbacks on a thread they control, removing the above restrictions and making basic C integrations simpler:
With both approaches, Carton loads the model (caching it locally if necessary).
275
+
276
+
Callbacks and notifications are available for every async function in Carton's interface.
277
+
278
+
For complete, runnable examples of loading and running a model from C, take a look at this [callback example](https://github.com/VivekPanyam/carton/blob/main/source/carton-bindings-c/tests/basic.c) or this [notifier example](https://github.com/VivekPanyam/carton/blob/main/source/carton-bindings-c/tests/notifier.c).
279
+
280
+
For more info on async functions in the Carton C interface, see [here](https://github.com/VivekPanyam/carton/blob/main/source/carton-bindings-c/README.md).
281
+
282
+
If you don't yet have a packed model, take a look at the [packing docs](/docs/packing) or explore the [community model registry](https://carton.pub).
It's possible to fetch model metadata without loading a model. This approach only fetches the data needed to provide the requested information and is therefore quite efficient even with large models.
This language currently does not support fetching model metadata. Please check the [quickstart guide](/quickstart) for more info or select a different language.
See the ["Loading a model"](/docs/loading) docs for complete examples of how to load a model and run inference.
87
+
88
+
At the moment, packing models and fetching metadata are not supported from C or C++.
89
+
90
+
</LanguageItem>
91
+
<LanguageItem>
92
+
11
93
```bash linePrompt='$' forLang='python'
12
94
pip install cartonml-nightly
13
95
```
@@ -296,6 +378,8 @@ async fn main() {
296
378
297
379
Carton routes all of its log messages to the console. If you want to see trace logging, you may need to enable the verbose log level in your browser's console.
0 commit comments