Joined: 27 Jun 2007, 16:05 Location: Moscow, Russia
I didn't quite understand the priority2 idea, but as far as synchronization goes, it should be ok, since thread 1 is blocked when thread 2 is doing stuff.
The idea is that Interface can survive AILib throwing errors, disconnecting and reconnecting to Interface multiple times.
When connection is missing (due to AI Lib Exception or just AI Lib being unloaded), each time handleEvent is fired, Interface checks if connections is present, and if it's not, tries to establish a session. This takes time (approximately 2 seconds).
The idea is to offload connection establishment loop to separate thread as when it's separate we don't care about this 2 seconds being lost in the default thread.
Yesterday night I built the prototype which runs three threads, one is default, one for client and one for server. It all works well, however I expect socket implementation is not thread safe as I'm getting errors inside sockets-related code sometimes. The problem could have been solved by mutex lock preceding every call to socket functions, however the server object in Apache Thrift is implemented as monolithic object, so it doesn't expose any event based callbacks or smth. One solution is to rewrite server code a little bit (thanks god it's open source), however I'm looking more into standard solutions. There should be ones available. Still checking options....
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum