Results 1 to 6 of 6

Thread: Threads

  1. #1
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default Threads

    EDIT: Let me rephrase. I'm making a multiplayer server that will have data feeds to the client (map data, etc). In the overview it states to make a worker thread in the slot function to handle net streams. I guess my question is, would I setup something similar to the thread sync demo found with CL, or something a little different? I'm totally new to threads, so some psuedo code would be awesome. I don't know if I'd just call a new CL_Thread and pass the run function to handle the download (and in that case, how does the thread shut down?), or what... ?

    Secondly, how threaded is the networking in ClanLib? If potentially several people would connect at the same time, do I have to thread the login routines, or are they handled in a threaded manner by clanlib? This might be a heavily occupied server (20+ clients), so I'm wondering if I need to add more threading than the stock netstream demo example provided with clan lib, because that's my basic model.

    Thanks in advance!

    -Dan
    Last edited by catch22; 06-27-2007 at 03:41 AM.

  2. #2
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default

    Bump for edit

  3. #3

    Default

    I don't know anything about the ClanLib networking, but for 20 clients I would think single thread login server would suffice. If your app doesn't require fast response times (i.e. non-FPS), a single-thread server would probably be enough and would avoid the complexity of locking.

    2 cents.

  4. #4
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default

    Absolutely true. I tend to aim small but think big. I'd hate to need more and be stuck with too little. Would rather have it and not need it than need it and not have it!

  5. #5
    Lesser Knight
    Join Date
    Sep 2006
    Posts
    41

    Default

    If I understand ClanLib's networking correctly (and someone else will probably correct me if I don't), the networking is already threaded.

    Those callback functions you connect to the networking signals? They don't get executed by your main thread, but by the networking thread. So you have to make sure that they can run concurrently with your main thread while avoiding race conditions and deadlocks.

  6. #6
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default

    Quote Originally Posted by Chambers View Post
    If I understand ClanLib's networking correctly (and someone else will probably correct me if I don't), the networking is already threaded.

    Those callback functions you connect to the networking signals? They don't get executed by your main thread, but by the networking thread. So you have to make sure that they can run concurrently with your main thread while avoiding race conditions and deadlocks.
    That aside, according to the net stream overview, one should set up a worker thread to handle a net stream for sending a map file, or whatever.

    I assume this is because the networking layer only operates on a single thread, and does not spawn a new thread per connection? Otherwise, I wouldn't think it would be necessary....

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •