@@ -17,6 +17,7 @@ This package is also available via LuaRocks, see https://luarocks.org/modules/os
1717[ Lua ] : https://www.lua.org
1818[ Lanes ] : https://luarocks.org/modules/benoitgermain/lanes
1919[ llthreads2 ] : https://luarocks.org/modules/moteus/lua-llthreads2
20+ [ carray ] : https://github.com/osch/lua-carray
2021
2122See below for full [ reference documentation] ( #documentation ) .
2223
@@ -92,6 +93,7 @@ assert(lst:nextmsg(0) == nil)
9293 * buffer: name ()
9394 * buffer: addmsg ()
9495 * buffer: setmsg ()
96+ * buffer: msgcnt ()
9597 * buffer: clear ()
9698 * buffer: nextmsg ()
9799 * buffer: notifier ()
@@ -308,7 +310,8 @@ assert(lst:nextmsg(0) == nil)
308310* ** ` buffer:addmsg(...) ` **
309311
310312 Adds the arguments together as one message to the buffer. Arguments can be
311- simple data types (string, number, boolean, nil, light user data, C function).
313+ simple data types (string, number, boolean, nil, light user data, C function)
314+ or [ carray] objects.
312315
313316 Returns * true* if the message could be added to the buffer.
314317
@@ -327,7 +330,7 @@ assert(lst:nextmsg(0) == nil)
327330
328331 Sets the arguments together as one message into the buffer. All other messages
329332 in this buffer are discarded. Arguments can be simple data types
330- (string, number, boolean, light user data, C function).
333+ (string, number, boolean, light user data, C function) or [ carray ] objects .
331334
332335 Returns * true* if the message could be set into the buffer.
333336
@@ -339,6 +342,10 @@ assert(lst:nextmsg(0) == nil)
339342 * mtmsg.error.operation_aborted*
340343
341344
345+ * ** ` buffer:msgcnt() ` **
346+
347+ Returns the number of messages in the buffer.
348+
342349* ** ` buffer:clear() ` **
343350
344351 Removes all messages from the buffer.
@@ -372,18 +379,28 @@ assert(lst:nextmsg(0) == nil)
372379 * mtmsg.error.operation_aborted*
373380
374381
375- * ** ` buffer:notifier(ntf) ` **
382+ * ** ` buffer:notifier(ntf[,type[,threshold]] ) ` **
376383
377384 Connects a notifier object to the underlying buffer.
378385
379- * * ntf* notifier object or * nil* . If * nil* is given, an existing notifier
380- object is disconnected from the underlying buffer.
381-
382- A connected notifier object is always called if a message is added to the
383- underlying buffer.
384-
385- A buffer can only have one connected notifier object. It is an error to call
386- this method in case the buffer already has a connected notifier object.
386+ * * ntf* notifier object or * nil* . If * nil* is given, an existing notifier
387+ object of the specified type is disconnected from the underlying buffer.
388+
389+ * * type* optional string, value "<" for a notifier that is notified if a message
390+ is removed from the buffer and ">" for a notifier that is notified if
391+ a message is added to the buffer. Default value is ">".
392+
393+ * * threshold* optional integer. For notifier type "<" the notifier is notified
394+ if the current number of messages is below the threshold after a
395+ message is removed from the buffer. For notifier type ">" the notifier
396+ is notifierd if the current number of message is above the threshold
397+ after a message is added to the buffer. If nil or not given
398+ the threshold is not considered. i.e. the corresponding notifier
399+ is always called if a message is removed or added.
400+
401+ A buffer can only have one connected notifier object per notifier type "<" or ">".
402+ It is an error to call this method in case the buffer already has a connected
403+ notifier object of the same type.
387404
388405 The given notifier object must implement the [ Notify C API] ,
389406 see [ src/notify_capi.h] ( ./src/notify_capi.h ) , i.e. the given object must
@@ -573,7 +590,8 @@ is equivalent to
573590* ** ` writer:add(...) ` **
574591
575592 Adds the arguments as message elements into the writer. Arguments can be
576- simple data types (string, number, boolean, nil, light user data, C function).
593+ simple data types (string, number, boolean, nil, light user data, C function)
594+ or [ carray] objects.
577595
578596 Possible errors: * mtmsg.error.message_size*
579597
0 commit comments