Results 1 to 2 of 2

Thread: Thread problem

  1. #1
    minifat is offline Registered User
    Name: Yan Yaqin
    Organization: CEPRI
    Project: data interface
    Join Date
    Jul 2004
    Location
    Beijing, China
    Posts
    40

    Thread problem

    Hello,

    I have a problem about using Ice to encapsulate some database operation api, like open(), readdata(), close().

    The database api require call attachdb() before visit database in thread different to the thread call open() , and call detach() when leave the thread. How can I encapsulate these details with Ice?
    I know that in default there's only one service thread beside the main thread. I plan to call open() in the main thread. But where can i detect the begin and the end of thread to call attach()/detach() operation?
    May someone give me any advice?

  2. #2
    bernard's Avatar
    bernard is offline ZeroC Staff
    Name: Bernard Normier
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Palm Beach Gardens, FL
    Posts
    1,294
    Hello,

    Your database seems a bit unusual (calling open in one thread, attach/detach in other threads); for example with XA, you would call xa_open, xa_start, xa_end from the same thread.

    You can insert code in the dispatching thread before and after the operation by using a Servant Locator: see "29.6.3 Threading Guarantees for Servant Locators" in the Ice manual.
    For example you could attach in locate() and detach in finished().

    If you need to detect whether a thread has been initialized or not, you could use thread-specific data or maintain your own map thread-id to someInfo.

    Cheers,
    Bernard

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Ice Thread Pool problem
    By alex_leshii in forum Help Center
    Replies: 7
    Last Post: 04-08-2012, 12:04 AM
  2. Thread problem while trying for a LISP interface
    By myrosia in forum Help Center
    Replies: 6
    Last Post: 10-28-2009, 01:04 PM
  3. Thread problem
    By areslp in forum Help Center
    Replies: 5
    Last Post: 03-25-2009, 06:29 AM
  4. Abort thread in C#
    By acbell in forum Help Center
    Replies: 1
    Last Post: 01-03-2006, 04:05 PM
  5. a thread problem
    By fw_csha in forum Help Center
    Replies: 2
    Last Post: 05-15-2005, 05:41 AM

Posting Permissions

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