[Vortex] General Vortex Library / BEEP concept questions

Jens Alfke jens at mooseyard.com
Fri Mar 28 18:36:51 CET 2008


On 28 Mar '08, at 10:05 AM, Robert M. Münch wrote:

> 1. Client/Server: Am I right, that BEEP clients and servers are  
> talking
> widly in a "request/response" model? So, the client is mostly the one
> initiating a request and the server returns some answer.

Yes. The model is that, over any particular channel, one party sends a  
message, then the other party responds with either a single response,  
multiple responses, or an error.

> Is it possible to setup a connection from a client to a server and  
> than
> have the server start a request? I think it should, because when
> registering a Profile, a frame-recieved handler can be specified.  
> And this
> is possible on the client and server.

Yes. Once the connection is opened, BEEP doesn't care who initiated  
it. Either peer can send messages and receive incoming messages.

The main limit on message sending is that each channel is FIFO: a  
message cannot be sent over a channel until the previous message has  
been replied to. In practice this isn't much of a problem, as you can  
just open another channel (with the same profile) if you need more  
parallelism.

> 2. I have a problem to create a binding to a scripting language. I use
> REBOL. The problem is that the interpreter crashes with a "stack  
> overflow"
> as soon as a REBOL callback is called from inside a vortex callback.

Vortex callbacks are usually made from worker threads, not the thread  
that you called Vortex on. This can cause problems if your code, or  
libraries that you're using, aren't completely thread-safe. Dynamic- 
language interpreters very often have such limitations.

What I've done to work around this is to write my Vortex callbacks to  
post messages to my main thread. The callbacks themselves don't use  
any of my APIs or any system code that isn't thread-safe.

The actual mechanism for posting messages to another thread depends on  
the OS and application framework you're using. I'm writing a Cocoa app  
for Mac OS X so I use NSRunLoop. But most frameworks have the notion  
of a event-loop and ways to post custom events/messages to it.

Another option is to create a global lock/mutex, and wrap it around  
all the places in your code where you use non-thread-safe  
functionality. (Python has a "Global Interpreter Lock".) In my  
experience, though, this is prone to bugs if you forget to wrap  
everything, and can cause deadlocks with other mutexes unless you  
order everything carefully. These days I much prefer message-passing.

—Jens
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1875 bytes
Desc: not available
Url : http://lists.aspl.es/pipermail/vortex/attachments/20080328/7f4fcb9a/attachment.bin 


More information about the Vortex mailing list