pelican/server/src/Session.cpp
/**
 * @details
 * Iterates over the list of data options (requirements) provided in the request
 * until a valid data object is returned.
 *
 * Returns the first data set available (streams and associated service data)
 * that match the requirements.
 *
 * An empty request will return immediately with an empty list.
 *
 * WARNING: This function will block until valid data matching the request can
 * made.
 *
 * The data will be returned as a locked container to ensure access by other
 * threads will be blocked. This is achieved by a signal emitted when the
 * LockedData object goes out of scope.
 *
 * @param[in] req       StreamDataRequest object containing a data requirements
 *                      iterator.
 * @param[in] timeout   Timeout in milliseconds. (0 = do not timeout)
 *
 * @return A list of locked data containing streams data object and their
 *         associated service data for the first request that can be fully
 *         satisfied.
 */
@details
Iterates over the list of data options (requirements) provided in the request
until a valid data object is returned.

Returns the first data set available (streams and associated service data)
that match the requirements.

An empty request will return immediately with an empty list.

This function will block until valid data matching the request can
made.

The data will be returned as a locked container to ensure access by other
threads will be blocked. This is achieved by a signal emitted when the
LockedData object goes out of scope.

@param[in] req       StreamDataRequest object containing a data requirements
iterator.
@param[in] timeout   Timeout in milliseconds. (0 = do not timeout)

@return A list of locked data containing streams data object and their
associated service data for the first request that can be fully
satisfied.
@details Iterates over the list of data options ( requirements ) provided in the request until a valid data object is returned . Returns the first data set available ( streams and associated service data ) that match the requirements . An empty request will return immediately with an empty list . This function will block until valid data matching the request can made . The data will be returned as a locked container to ensure access by other threads will be blocked . This is achieved by a signal emitted when the LockedData object goes out of scope . @param [ in ] req StreamDataRequest object containing a data requirements iterator . @param [ in ] timeout Timeout in milliseconds . ( 0 = do not timeout ) @return A list of locked data containing streams data object and their associated service data for the first request that can be fully satisfied .
QList<LockedData> Session::processStreamDataRequest(const StreamDataRequest& req,
        const unsigned timeout)
{
    QList<LockedData> dataList;
    if (req.isEmpty()) {
        verbose("StreamData request is empty");
        return dataList;
    }
    QTime time;
    time.start();
    verbose("processing StreamData request");
    while (dataList.size() == 0)
    {
        if ((unsigned int)time.elapsed() > timeout && timeout > 0) {
            throw QString("Session::processStreamDataRequest():"
            " Request timed out after %1 ms.").arg(time.elapsed());
        }
        DataSpecIterator it = req.begin();
        while(it != req.end() && dataList.size() == 0) {
            dataList = _dataManager->getDataRequirements(*it);
            ++it;
        }
        usleep(1);
    }
    verbose("finished processing StreamData request");
    return dataList;
}
QList < LockedData > Session :: processStreamDataRequest ( const StreamDataRequest & req , const unsigned timeout ) { QList < LockedData > dataList ; if ( req . isEmpty ( ) ) { verbose ( " " ) ; return dataList ; } QTime time ; time . start ( ) ; verbose ( " " ) ; while ( dataList . size ( ) == 0 ) { if ( ( unsigned int ) time . elapsed ( ) > timeout && timeout > 0 ) { throw QString ( " " " " ) . arg ( time . elapsed ( ) ) ; } DataSpecIterator it = req . begin ( ) ; while ( it != req . end ( ) && dataList . size ( ) == 0 ) { dataList = _dataManager -> getDataRequirements ( * it ) ; ++ it ; } usleep ( 1 ) ; } verbose ( " " ) ; return dataList ; }
@details
 Iterates over the list of data options (requirements) provided in the request
 until a valid data object is returned.
@details Iterates over the list of data options ( requirements ) provided in the request until a valid data object is returned .
// Return an empty list if there are no data requirements in the request. // Start a timer to handle the timeout. // Iterate until the data requirements can be satisfied. // keep spinning until we either get data or time out.