|
| ofURLFileLoaderImpl () |
|
| ~ofURLFileLoaderImpl () |
|
ofHttpResponse | get (const string &url) |
|
int | getAsync (const string &url, const string &name="") |
|
ofHttpResponse | saveTo (const string &url, const of::filesystem::path &path) |
|
int | saveAsync (const string &url, const of::filesystem::path &path) |
|
void | remove (int id) |
| remove an active HTTP request from the queue
|
|
void | clear () |
| clear all active HTTP requests from the queue
|
|
void | stop () |
| stop & remove all active and waiting HTTP requests
|
|
ofHttpResponse | handleRequest (const ofHttpRequest &request) |
| low level HTTP request implementation blocks until a response is returned or the request times out
|
|
int | handleRequestAsync (const ofHttpRequest &request) |
|
| ofThread () |
| Create an ofThread.
|
|
bool | isThreadRunning () const |
| Check the running status of the thread.
|
|
std::thread::id | getThreadId () const |
| Get the unique thread id.
|
|
std::string | getThreadName () const |
| Get the unique thread name, in the form of "Thread id#".
|
|
void | setThreadName (const std::string &name) |
|
void | startThread () |
| Start the thread.
|
|
| OF_DEPRECATED_MSG ("Use tryLock instead of setting the type of lock on startThread", void startThread(bool mutexBlocks)) |
| Start the thread with options.
|
|
bool | lock () |
| Lock the mutex.
|
|
bool | tryLock () |
| Tries to lock the mutex.
|
|
void | unlock () |
| Unlock the mutex.
|
|
void | stopThread () |
| Stop the thread.
|
|
void | waitForThread (bool callStopThread=true, long milliseconds=INFINITE_JOIN_TIMEOUT) |
| Wait for the thread to exit (aka "joining" the thread).
|
|
void | sleep (long milliseconds) |
| Tell the thread to sleep for a certain amount of milliseconds.
|
|
void | yield () |
| Tell the thread to give up its CPU time other threads.
|
|
bool | isCurrentThread () const |
| Query whether the current thread is active.
|
|
std::thread & | getNativeThread () |
| Get a reference to the underlying Poco thread.
|
|
const std::thread & | getNativeThread () const |
| Get a const reference to the underlying Poco thread.
|
|
virtual | ~ofBaseURLFileLoader () |
|
virtual ofHttpResponse | get (const std::string &url)=0 |
| make an HTTP request blocks until a response is returned or the request times out
|
|
virtual int | getAsync (const std::string &url, const std::string &name="")=0 |
| make an asynchronous HTTP request will not block, placed in a queue and run using a background thread
|
|
virtual ofHttpResponse | saveTo (const std::string &url, const of::filesystem::path &path)=0 |
| make an HTTP request and save the response data to a file blocks until a response is returned or the request times out
|
|
virtual int | saveAsync (const std::string &url, const of::filesystem::path &path)=0 |
| make an asynchronous HTTP request and save the response data to a file will not block, placed in a queue and run using a background thread
|
|
void ofURLFileLoaderImpl::threadedFunction |
( |
| ) |
|
|
protectedvirtual |
The thread's run function.
Users must overide this in your their derived class and then implement their threaded activity inside the loop. If the the users's threadedFunction does not have a loop, the contents of the threadedFunction will be executed once and the thread will then exit.
For tasks that must be repeated, the user can use a while loop that will run repeatedly until the thread's threadRunning is set to false via the stopThread() method.
void MyThreadedClass::threadedFunction()
{
// Start the loop and continue until
// isThreadRunning() returns false.
while(isThreadRunning())
{
// Do activity repeatedly here:
// int j = 1 + 1;
// This while loop will run as fast as it possibly
// can, consuming as much processor speed as it can.
// To help the processor stay cool, users are
// encouraged to let the while loop sleep via the
// sleep() method, or call the yield() method to let
// other threads have a turn. See the sleep() and
// yield() methods for more information.
// sleep(100);
}
}
Reimplemented from ofThread.