VirtualBox

Changeset 7162 in vbox


Ignore:
Timestamp:
Feb 27, 2008 2:28:43 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
28452
Message:

r=bird: some missing docs, fixed incorrect cleanup order and made cleanup a little bit faster (user sem, not sleep).

Location:
trunk/src/VBox/HostServices/SharedClipboard
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedClipboard/Makefile.kmk

    r7117 r7162  
    3737        clipboard-helper.cpp \
    3838        darwin-pasteboard.cpp
    39 if1of ($(BUILD_TARGET),linux solaris)
     39if1of ($(BUILD_TARGET),linux solaris) ## @todo X11
    4040 ifndef VBOX_HEADLESS
    4141  VBoxSharedClipboard_SOURCES += \
  • trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp

    r7131 r7162  
    3434//#define SHOW_CLIPBOARD_CONTENT
    3535
     36/** @todo r=bird: document these functions */
     37
    3638int initPasteboard (PasteboardRef *pPasteboardRef)
    3739{
  • trunk/src/VBox/HostServices/SharedClipboard/darwin.cpp

    r7123 r7162  
    4343static VBOXCLIPBOARDCONTEXT g_ctx;
    4444
    45 int vboxClipboardChanged (VBOXCLIPBOARDCONTEXT *pCtx)
     45
     46/**
     47 * Checks if something is present on the clipboard and calls vboxSvcClipboardReportMsg.
     48 *
     49 * @returns IPRT status code (ignored).
     50 * @param   pCtx    The context.
     51 *
     52 * @todo r=bird: This function does not check if something has _changed_ like indicated by
     53 *               the name. It will instead notify the client every 200ms as long as something
     54 *               is on the clipboard. When the clipboard is cleared it will do nothing.
     55 *               I somehow cannot think that this intentional behavior...
     56 */
     57static int vboxClipboardChanged (VBOXCLIPBOARDCONTEXT *pCtx)
    4658{
    4759    if (pCtx->pClient == NULL)
     
    6173}
    6274
    63 static int vboxClipboardThread (RTTHREAD self, void *pvUser)
     75
     76/**
     77 * The poller thread.
     78 *
     79 * This thread will check for the arrival of new data on the clipboard.
     80 *
     81 * @returns VINF_SUCCESS (not used).
     82 * @param   Thread      Our thread handle.
     83 * @param   pvUser      Pointer to the VBOXCLIPBOARDCONTEXT structure.
     84 *
     85 */
     86static int vboxClipboardThread (RTTHREAD ThreadSelf, void *pvUser)
    6487{
    6588    Log (("vboxClipboardThread: starting clipboard thread\n"));
    6689
    67     AssertReturn (VALID_PTR (pvUser), VERR_INVALID_PARAMETER);
    68 
    69     VBOXCLIPBOARDCONTEXT *pCtx = static_cast <VBOXCLIPBOARDCONTEXT*> (pvUser);
     90    AssertPtrReturn (pvUser, VERR_INVALID_PARAMETER);
     91    VBOXCLIPBOARDCONTEXT *pCtx = (VBOXCLIPBOARDCONTEXT *) pvUser;
    7092
    7193    while (!pCtx->fTerminate)
    7294    {
    73        vboxClipboardChanged (pCtx);
    74        /* Sleep for 200 msecs before next poll */
    75        RTThreadSleep (200);
    76     }
    77 
    78     Log (("vboxClipboardThread: clipboard thread terminated successfully with return code %Vrc\n", VINF_SUCCESS));
     95        vboxClipboardChanged (pCtx);
     96        /* Sleep for 200 msecs before next poll */
     97        RTThreadUserWait (self, 200);
     98    }
     99
     100    Log (("vboxClipboardThread: clipboard thread terminated successfully with return code %Rrc\n", VINF_SUCCESS));
    79101    return VINF_SUCCESS;
    80102}
     
    89111    Log (("vboxClipboardInit\n"));
    90112
    91     int rc = VINF_SUCCESS;
    92 
    93113    g_ctx.fTerminate = false;
    94114
    95     rc = initPasteboard (&g_ctx.pasteboard);
     115    int rc = initPasteboard (&g_ctx.pasteboard);
     116    AssertRCReturn (rc, rc);
    96117
    97118    rc = RTThreadCreate (&g_ctx.thread, vboxClipboardThread, &g_ctx, 0,
    98119                         RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "SHCLIP");
     120    if (RT_FAILURE (rc))
     121    {
     122        g_ctx.thread = NIL_RTTHREAD;
     123        destroyPasteboard (&g_ctx.pasteboard);
     124    }
    99125
    100126    return rc;
     
    106132    Log (("vboxClipboardDestroy\n"));
    107133
    108     g_ctx.fTerminate = true;
    109 
     134    /*
     135     * Signal the termination of the polling thread and wait for it to respond.
     136     */
     137    ASMAtomicWriteBool (&g_ctx.fTerminate, true);
     138    int rc = RTThreadUserSignal (g_ctx.thread);
     139    AssertRC (rc);
     140    rc = RTThreadWait (g_ctx.thread, RT_INDEFINITE_WAIT, NULL);
     141    AssertRC (rc);
     142
     143    /*
     144     * Destroy the pasteboard and uninitialize the global context record.
     145     */
    110146    destroyPasteboard (&g_ctx.pasteboard);
    111 
    112     /* Wait for the clipboard thread to terminate. */
    113     RTThreadWait (g_ctx.thread, RT_INDEFINITE_WAIT, NULL);
    114 
    115147    g_ctx.thread = NIL_RTTHREAD;
    116 }
    117 
    118 /**
    119   * Enable the shared clipboard - called by the hgcm clipboard subsystem.
    120   *
    121   * @param   pClient Structure containing context information about the guest system
    122   * @returns RT status code
    123   */
     148    g_ctx.pClient = NULL;
     149}
     150
     151/**
     152 * Enable the shared clipboard - called by the hgcm clipboard subsystem.
     153 *
     154 * @param   pClient Structure containing context information about the guest system
     155 * @returns RT status code
     156 */
    124157int vboxClipboardConnect (VBOXCLIPBOARDCLIENTDATA *pClient)
    125158{
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette