I'm trying to write a fairly simple threaded application, but am new to boost's thread library. A simple test program I'm working on is:
#include <iostream>
#include <boost/thread.hpp>
int result = 0;
boost::mutex result_mutex;
boost::thread_group g;
void threaded_function(int i)
{
for(; i < 100000; ++i) {}
{
boost::mut...
I'm trying to send two events to the main window so that I can show some kind of animation that will let the user know that I'm updating the data.
This is an ObservableCollection object so the OnPropertyChanged is immediately picked up by the bindings on the main window. The sleep is only in there so that the user can see the animation...
Our Tomcat web application feels slow when it is used by a couple hundred users. The servers are in a hosting company and their reports doesn't show any problem with bandwith or cpu workload, so I suspect that the reason of the slowdowns can be because of contention on some legacy code that we encapsulated under synchronized calls becaus...
I have an ASP.NET MVC application that currently uses the WebClient class to make a simple call to an external web service from within a controller action.
Currently I am using the DownloadString method, which runs synchronously. I have run into issues where the external web service is unresponsive, which results in my entire ASP.NET ap...
I understand that if you specify thread priorities other than the default in Java then it makes the program platform specific. If you were to create threads for an android application and modify the priorities then would the app platform specific across different android versions (i.e. Cupcake/Donut and modified versions of Android like...
Hi.
I want to make 3 threads that each run the WebBroswer control. So I would like to use the ThreadPool to make things easy.
for(int i = 0;i < 3;i++)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(gotoWork), i));
}
WaitAll(waitHandles);
....../
void gotoWork(object o)
{
string url = String.Empty;
int num = (int)o;
...
Let me first say that I have quite a lot of Java experience, but have only recently become interested in functional languages. Recently I've started looking at Scala, which seems like a very nice language.
However, I've been reading about Scala's Actor framework in Programming in Scala, and there's one thing I don't understand. In chapt...
I am trying to use threads in Perl, but I get the following errors when I do require threads:
~ > perl -e 'require threads'
threads object version 1.07 does not match bootstrap parameter 1.71 at /System/Library/Perl/5.8.8/darwin-thread-multi-2level/XSLoader.pm line 94.
Compilation failed in require at -e line 1.
I am using OS X 10.5.7...
What is a way to simply wait for all threaded process to finish? For example, let's say I have:
public class DoSomethingInAThread implements Runnable{
public static void main(String[] args) {
for (int n=0; n<1000; n++) {
Thread t = new Thread(new DoSomethingInAThread());
t.start();
}
// wait for all t...
Right now I do:
Util.AssertBackgroundThread();
or
Util.AssertUIThread();
at the start of the methods. This is not too bad, but it's runtime error checking. The reason we use static languages like C# is to move more of the error checking onto the compiler's shoulders.
Now I don't think this is generally easy, but if I restrict myself...
The OpenGL ES rendering loop is placed on a separate thread in my iphone application. Everything goes fine except that the EAGLContext's presentRenderbuffer method fails. The result is a blank white screen.
When the same code is run on the main thread, presentRenderbuffer succeeds and the graphics is properly shown.
What is the correct ...
I have application which works with 2 threads in first I have main windowa and almost whole logic, in other I run a preloader which is shown when user have to wait a a little more time for an results. When i introduced the second thread into my app I have seemed a different occurrence. When i open some modal window in main thread and i ...
Let's take Wes Dyer's approach to function memoization as the starting point:
public static Func<A, R> Memoize<A, R>(this Func<A, R> f)
{
var map = new Dictionary<A, R>();
return a =>
{
R value;
if (map.TryGetValue(a, out value))
return value;
value = f(a);
map.Add(a, value);
return value;
...
In a project I'm working on, I have a main class (named TrackWin) that extends JFrame. In this frame, I make use of a JTabbedPane.
A user can create a new tab in the pane from the Menu Bar. Whenever this occurs, tabbedPane.addTab() is called in TrackWin.
I also have a class called TrackTab, which extends JPanel. This class contains a...
I have these two methods for thread-exclusive access to a CMyBuffer object:
Header:
class CSomeClass
{
//...
public:
CMyBuffer & LockBuffer();
void ReleaseBuffer();
private:
CMyBuffer m_buffer;
CCriticalSection m_bufferLock;
//...
}
Implementation:
CMyBuffer & CSomeClass::LockBuffer()
{
m_bufferLock.Lock();
...
Does java.util.concurrent.atomic.AtomicBoolean not have a method that can atomically negate/invert the value? Can I do it another way? Am I missing something?
...
Windows provides a number of objects useful for synchronising threads, such as event (with SetEvent and WaitForSingleObject), mutexes and critical sections.
Personally I have always used them, especially critical sections since I'm pretty certain they incur very little overhead unless already locked. However, looking at a number of libr...
I've been using boost::mutex::scoped_lock in this manner:
void ClassName::FunctionName()
{
{
boost::mutex::scoped_lock scopedLock(mutex_);
//do stuff
waitBoolean=true;
}
while(waitBoolean == true ){
sleep(1);
}
//get on with the thread's activities
}
Basically it sets waitBoolean, and the ...
Why is it that if I call a seemingly synchronous Windows function like MessageBox() inside of my message loop, the loop itself doesn't freeze as if I called Sleep() (or a similar function) instead? To illustrate my point, take the following skeletal WndProc:
int counter = 0;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, ...
I have created a Windows Form App for Managed Care(CRUD of Member Data). It is an internal app that uses Merge Replication to allow field use. The app basically follows this structure:
Form Shell
Form MemberHost
Form Member
Form MemberContacts
Form MemberInsurance
Form Enrollments
Form CaseNotes
Form MemberCenteredPlanHost
Form M...