[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
.oct files - keeping state across calls
From: |
Christophe Tournery |
Subject: |
.oct files - keeping state across calls |
Date: |
Mon, 6 Jul 2009 14:18:58 +0200 |
Hi all,
I am looking for a best practice advice regarding .oct files in octave
3.2
Description:
------------
I am writing an oct file wrapper around a C library. The library
performs block processing of audio files (similar to fft block
processing). However the library needs to keep its internal state
across calls to its "process" function. Therefore I am using an init
function to initialize this internal state and return a handle to it,
such that multiple instances of the library can be used at the same
time. Usage in octave is in pseudo code:
handle = mylib_init()
for (...)
y = mylib_process(handle, x)
...
end
mylib_destroy(handle)
The oct file (.cc) must keep track of the allocated handles and
internal states which are C structures. One way of doing it is to get
rid of the handle and return the internal state in octave's user
space. However those can be a bit large and are useless to the caller
so I'd rather keep them hidden inside the oct file, hence the handle
which reduces complexity and improves performance by avoiding
unnecessary copies of data.
Problem:
--------
Both mylib_init() and mylib_process() must share a list of allocated
handles and internal states of mylib. In octave 3.0 I used a static
std::map in my .cc file for the handles and that worked. In octave 3.2
this fails. It seems that in 3.2 the .oct file is loaded twice, once
for mylib_init() and once for mylib_process(), therefore the static
variable trick does not work anymore since they have different
addresses.
Any suggestions?
Thanks in advance
Christophe Tournery
- .oct files - keeping state across calls,
Christophe Tournery <=
- Re: .oct files - keeping state across calls, dbateman, 2009/07/06
- Re: .oct files - keeping state across calls, Christophe Tournery, 2009/07/07
- Re: .oct files - keeping state across calls, David Bateman, 2009/07/09
- Re: .oct files - keeping state across calls, Christophe Tournery, 2009/07/13
- Re: .oct files - keeping state across calls, John W. Eaton, 2009/07/13
- Re: .oct files - keeping state across calls, Christophe Tournery, 2009/07/14
- Re: .oct files - keeping state across calls, John W. Eaton, 2009/07/14
- Re: .oct files - keeping state across calls, Christophe Tournery, 2009/07/22
- Re: .oct files - keeping state across calls, John W. Eaton, 2009/07/14
- Re: .oct files - keeping state across calls, Christophe Tournery, 2009/07/14